|
@@ -86,16 +86,24 @@ func checkAllRulesOnField(field int) bool {
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+var validTickets []ticket
|
|
|
|
+
|
|
func sumBad() int {
|
|
func sumBad() int {
|
|
numberOfTickets := len(tickets)
|
|
numberOfTickets := len(tickets)
|
|
sum := 0
|
|
sum := 0
|
|
|
|
|
|
for i := 1; i < numberOfTickets; i++ {
|
|
for i := 1; i < numberOfTickets; i++ {
|
|
|
|
+ validTicket := true
|
|
for _, field := range tickets[i] {
|
|
for _, field := range tickets[i] {
|
|
if !checkAllRulesOnField(field) {
|
|
if !checkAllRulesOnField(field) {
|
|
sum += field
|
|
sum += field
|
|
|
|
+ validTicket = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if validTicket {
|
|
|
|
+ validTickets = append(validTickets, tickets[i])
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return sum
|
|
return sum
|
|
@@ -119,4 +127,5 @@ func main() {
|
|
}
|
|
}
|
|
|
|
|
|
fmt.Println("Part1:", sumBad())
|
|
fmt.Println("Part1:", sumBad())
|
|
|
|
+ fmt.Println(validTickets)
|
|
}
|
|
}
|