solve part 2 of day 5

This commit is contained in:
Nico 2020-12-05 14:13:42 +00:00
parent fb159a9a6d
commit a6eafd7e55
1 changed files with 12 additions and 1 deletions

13
five.go
View File

@ -3,6 +3,7 @@ package main
import (
"fmt"
"io/ioutil"
"sort"
"strings"
)
@ -18,6 +19,7 @@ func main() {
d, _ := ioutil.ReadFile("in5.txt")
s := strings.Split(string(d), "\n")
max := 0
var ids []int
for _, code := range s {
rowUpper := 127
rowLower := 0
@ -55,9 +57,18 @@ func main() {
}
}
id := row*8 + col
ids = append(ids, id)
if id > max {
max = id
}
}
fmt.Println(max)
sort.Ints(ids)
fmt.Println("Highest ID: ", max)
prev := 0
for _, d := range ids {
if prev != 0 && prev+1 != d {
fmt.Println("Missing Seat: ", d-1)
}
prev = d
}
}