You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
403 B

package day05
import (
"log"
"sort"
)
func Solve2() {
var seatIds []int
var missingSeat int
for _, row := range rows {
seatIds = append(seatIds, getSeatId(row))
}
sort.Ints(seatIds)
lastId := seatIds[0] - 1
for _, seatId := range seatIds {
if lastId != seatId-1 {
missingSeat = seatId - 1
break
}
lastId = seatId
}
log.Printf("2020-12-05.02: Answer: %d\n", missingSeat)
}