rename function to more accurately describe what it does

This commit is contained in:
David 2020-12-07 19:20:06 -05:00
parent e4c2848a88
commit 0f15711b6a

View File

@ -22,7 +22,7 @@ type Bag struct {
seen bool
}
func lineToBags(s string) (string, map[string]int) {
func parseLine(s string) (string, map[string]int) {
bags := strings.Split(s, " bags contain ")
if bags[1] == "no other bags." {
return bags[0], map[string]int{}
@ -72,7 +72,7 @@ func partOne() {
for scanner.Scan() {
line := scanner.Text()
bag, contains := lineToBags(line)
bag, contains := parseLine(line)
// create bag if it doesn't already exist
if _, ok := bags[bag]; !ok {
@ -135,7 +135,7 @@ func partTwo() {
for scanner.Scan() {
line := scanner.Text()
bag, contains := lineToBags(line)
bag, contains := parseLine(line)
// create bag if it doesn't already exist
if _, ok := bags[bag]; !ok {