Day 6 part 1

master
Araozu 2024-03-01 15:45:33 -05:00
parent 6b5c65a811
commit 3624aa24bb
2 changed files with 38 additions and 0 deletions

View File

@ -21,6 +21,9 @@ func main() {
runAndBenchmark("05", "1", false, solutions.Day05Part01) runAndBenchmark("05", "1", false, solutions.Day05Part01)
runAndBenchmark("05", "2", false, solutions.Day05Part02) runAndBenchmark("05", "2", false, solutions.Day05Part02)
runAndBenchmark("06", "1", false, solutions.Day06Part01)
runAndBenchmark("06", "2", false, solutions.Day06Part02)
} }
type execute func(bool) int type execute func(bool) int

35
solutions/day06.go Normal file
View File

@ -0,0 +1,35 @@
package solutions
import (
"strings"
)
func Day06Part01(isTest bool) int {
input := ReadInput("06", isTest)
groups := strings.Split(input, "\n\n")
sum := 0
for _, group := range groups {
frequency := make(map[rune]int)
for _, letter := range group {
// remove non a-z character
if letter < 97 || letter > 122 {
continue
}
previousValue, _ := frequency[letter]
frequency[letter] = previousValue + 1
}
sum += len(frequency)
}
return sum
}
func Day06Part02(isTest bool) int {
return -1
}