aoc2023/day-4/two.go

19 lines
334 B
Go

package main
// two returns the total number of occurrences for all cards
func two(lines []string) (int, error) {
var sum = 0
for i := range cards {
cards[i].occurrences++
for j := i + 1; j <= i+cards[i].matches; j++ {
cards[j].occurrences += cards[i].occurrences
}
sum += cards[i].occurrences
}
return sum, nil
}