Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- e = [[0]*12] + [list(map(int,list('0'+i.replace("\n","")+'0'))) for i in open('input11.txt').read().split("\n")] + [[0]*12]
- flashdb,steps,simflash = 0,0,0
- while(simflash < 100):
- flashed = True
- simflash=0
- while (flashed):
- flashed = False
- for i in range(1,11):
- for j in range(1,11):
- if (e[i][j] > 9):
- e[i][j] = 0
- for k in [[1,0],[1,1],[1,-1],[-1,0],[-1,+1],[-1,-1],[0,1],[0,-1]]:
- if e[i+k[0]][j+k[1]] != 0:
- e[i+k[0]][j+k[1]]+=1
- simflash+=1
- flashed = True
- if steps == 101: print('part 1:',flashdb)
- flashdb+=simflash
- e = [[a+1 for a in b] for b in e]
- steps+=1
- print('part 2:',steps-1)
Add Comment
Please, Sign In to add comment