From 3edddbd7fcc6ac97e8f878ccdf774cab4071d183 Mon Sep 17 00:00:00 2001 From: Alexander Avery Date: Fri, 1 Dec 2023 23:33:09 -0500 Subject: [PATCH] account for shared starting and ending runes --- day01.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/day01.go b/day01.go index dedb803..b15c63b 100644 --- a/day01.go +++ b/day01.go @@ -35,31 +35,31 @@ func findtextdigits(line string) []rune { if strings.HasPrefix(line, "one") { d = append(d, '1') - line = line[3:] + line = line[2:] } else if strings.HasPrefix(line, "two") { d = append(d, '2') - line = line[3:] + line = line[2:] } else if strings.HasPrefix(line, "three") { d = append(d, '3') - line = line[5:] + line = line[4:] } else if strings.HasPrefix(line, "four") { d = append(d, '4') - line = line[4:] + line = line[4:] // skip len("four") entirely because no digits start with 'r' } else if strings.HasPrefix(line, "five") { d = append(d, '5') - line = line[4:] + line = line[3:] } else if strings.HasPrefix(line, "six") { d = append(d, '6') - line = line[3:] + line = line[3:] // skip len("six") entirely because no digits start with 'x' } else if strings.HasPrefix(line, "seven") { d = append(d, '7') - line = line[5:] + line = line[4:] } else if strings.HasPrefix(line, "eight") { d = append(d, '8') - line = line[5:] + line = line[4:] } else if strings.HasPrefix(line, "nine") { d = append(d, '9') - line = line[4:] + line = line[3:] } else { line = line[1:] }