mirror of
https://github.com/onyx-and-iris/aoc2023.git
synced 2024-11-15 15:10:49 +00:00
19 lines
334 B
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
|
|
}
|