Day 6 part 1
This commit is contained in:
parent
6b5c65a811
commit
3624aa24bb
3
main.go
3
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
|
||||
|
35
solutions/day06.go
Normal file
35
solutions/day06.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user