diff --git a/main.go b/main.go index af35bcd..a5b51ef 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,9 @@ func main() { runAndBenchmark("05", "1", false, solutions.Day05Part01) runAndBenchmark("05", "2", false, solutions.Day05Part02) + + runAndBenchmark("06", "1", false, solutions.Day06Part01) + runAndBenchmark("06", "2", false, solutions.Day06Part02) } type execute func(bool) int diff --git a/solutions/day06.go b/solutions/day06.go new file mode 100644 index 0000000..73ddc25 --- /dev/null +++ b/solutions/day06.go @@ -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 +}