parent
b73be6a838
commit
293d068777
3 changed files with 52 additions and 0 deletions
@ -0,0 +1,32 @@ |
|||||||
|
lines = [ [int(j) for j in list(i)] for i in open("input.txt", 'r').read().splitlines()] |
||||||
|
|
||||||
|
flashes = 0 |
||||||
|
for i in range(100): |
||||||
|
lines = [ [x+1 for x in y] for y in lines] |
||||||
|
flashed = True |
||||||
|
while flashed: |
||||||
|
flashed = False |
||||||
|
for x in range(10): |
||||||
|
for y in range(10): |
||||||
|
if lines[x][y] > 9: |
||||||
|
flashes += 1 |
||||||
|
lines[x][y] = 0 |
||||||
|
flashed = True |
||||||
|
if x != 0 and lines[x-1][y] != 0: |
||||||
|
lines[x-1][y] += 1 |
||||||
|
if x != 0 and y != 9 and lines[x-1][y+1] != 0: |
||||||
|
lines[x-1][y+1] += 1 |
||||||
|
if y != 9 and lines[x][y+1] != 0: |
||||||
|
lines[x][y+1] += 1 |
||||||
|
if x != 9 and y != 9 and lines[x+1][y+1] != 0: |
||||||
|
lines[x+1][y+1] += 1 |
||||||
|
if x != 9 and lines[x+1][y] != 0: |
||||||
|
lines[x+1][y] += 1 |
||||||
|
if x != 9 and y != 0 and lines[x+1][y-1] != 0: |
||||||
|
lines[x+1][y-1] += 1 |
||||||
|
if y != 0 and lines[x][y-1] != 0: |
||||||
|
lines[x][y-1] += 1 |
||||||
|
if x != 0 and y != 0 and lines[x-1][y-1] != 0: |
||||||
|
lines[x-1][y-1] += 1 |
||||||
|
|
||||||
|
print(flashes) |
@ -0,0 +1,10 @@ |
|||||||
|
5723573158 |
||||||
|
3154748563 |
||||||
|
4783514878 |
||||||
|
3848142375 |
||||||
|
3637724151 |
||||||
|
8583172484 |
||||||
|
7747444184 |
||||||
|
1613367882 |
||||||
|
6228614227 |
||||||
|
4732225334 |
@ -0,0 +1,10 @@ |
|||||||
|
5483143223 |
||||||
|
2745854711 |
||||||
|
5264556173 |
||||||
|
6141336146 |
||||||
|
6357385478 |
||||||
|
4167524645 |
||||||
|
2176841721 |
||||||
|
6882881134 |
||||||
|
4846848554 |
||||||
|
5283751526 |
Loading…
Reference in new issue