package main // Cards represents a single card. // it tracks its matching numbers and occurrences type Card struct { matches int occurrences int } var cards = []Card{} // 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 }