aoc21/d11/p1.go

29 lines
401 B
Go
Raw Normal View History

2022-04-03 22:38:47 +03:00
package d11
func reset(grid grid) {
for y, line := range grid {
for x := range line {
grid[y][x].flashed = false
}
}
}
func flash(grid grid) int {
lights := 0
for i := 0; i < 100; i++ {
for y, line := range grid {
for x := range line {
lights += incr(x, y, grid)
}
}
reset(grid)
}
return lights
}
func P1(in string) int {
grid := createGrid(in)
return flash(grid)
}