1 """ Simulate octopus flashing """
3 def increment(octopodes, position):
4 for x in range(position[0] - 1, position[0] + 2):
8 for y in range(position[1] - 1, position[1] + 2):
15 def add_one(octopodes):
24 flashed_this_iter = True
25 while flashed_this_iter:
26 flashed_this_iter = False
29 if octopodes[y][x] > 9 and (x, y) not in flashed:
30 flashed_this_iter = True
31 flashed.append((x, y))
32 increment(octopodes, (x, y))
41 with open("11_input.txt", "r") as f:
43 octopodes_in_line = []
44 for char in line.strip():
45 octopodes_in_line.append(int(char))
47 octopodes.append(octopodes_in_line)
50 for gen in range(100):
52 total_flashes += flash(octopodes)