12a
This commit is contained in:
@ -49,14 +49,14 @@ class Day11: Runnable {
|
||||
.map { Array($0) }
|
||||
.map { ar in ar.map {c in Int(c.description)!} }
|
||||
|
||||
for _ in 0..<100 {
|
||||
var step = 0
|
||||
while(flashed.count < numRows * numCols) {
|
||||
flashed = Set<Coord>()
|
||||
for row in octopuses.indices {
|
||||
for col in octopuses[row].indices {
|
||||
octopuses[row][col] += 1
|
||||
}
|
||||
}
|
||||
|
||||
for row in octopuses.indices {
|
||||
for col in octopuses[row].indices {
|
||||
let coord = Coord(row: row, col: col)
|
||||
@ -66,8 +66,12 @@ class Day11: Runnable {
|
||||
for flash in flashed {
|
||||
octopuses[flash] = 0
|
||||
}
|
||||
step += 1
|
||||
if step == 100 {
|
||||
print(numFlashes)
|
||||
}
|
||||
}
|
||||
print(numFlashes)
|
||||
print("All flashing at step: \(step)")
|
||||
}
|
||||
|
||||
func checkAndFlash(at coord: Coord) {
|
||||
|
Reference in New Issue
Block a user