1 """ Simulate octopus flashing """
5 def increment(octopodes, position):
6 for x in range(position[0] - 1, position[0] + 2):
10 for y in range(position[1] - 1, position[1] + 2):
17 def add_one(octopodes):
26 flashed_this_iter = True
27 while flashed_this_iter:
28 flashed_this_iter = False
31 if octopodes[y][x] > 9 and (x, y) not in flashed:
32 flashed_this_iter = True
33 flashed.append((x, y))
34 increment(octopodes, (x, y))
43 display_row.append("X")
45 display_row.append(".")
46 print("".join(display_row))
53 with open("11_input.txt", "r") as f:
55 octopodes_in_line = []
56 for char in line.strip():
57 octopodes_in_line.append(int(char))
59 octopodes.append(octopodes_in_line)
62 for gen in range(1, 100000000):
64 print("###", gen, "###")
65 if flash(octopodes) == 100: