Day 6 part 2
This commit is contained in:
parent
3624aa24bb
commit
0b67ae4aad
@ -30,6 +30,30 @@ func Day06Part01(isTest bool) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Day06Part02(isTest bool) int {
|
func Day06Part02(isTest bool) int {
|
||||||
|
input := ReadInput("06", isTest)
|
||||||
|
groups := strings.Split(input, "\n\n")
|
||||||
|
|
||||||
return -1
|
sum := 0
|
||||||
|
|
||||||
|
for _, group := range groups {
|
||||||
|
persons := strings.Split(group, "\n")
|
||||||
|
personAmount := len(persons)
|
||||||
|
|
||||||
|
frequency := make(map[rune]int)
|
||||||
|
|
||||||
|
for _, person := range persons {
|
||||||
|
for _, letter := range person {
|
||||||
|
previousValue, _ := frequency[letter]
|
||||||
|
frequency[letter] = previousValue + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, value := range frequency {
|
||||||
|
if value == personAmount {
|
||||||
|
sum += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user