From 6aba85fae4695b5b581689a98e5be0e7b0472d97 Mon Sep 17 00:00:00 2001 From: kwout Date: Sat, 11 Feb 2023 14:00:18 -0500 Subject: [PATCH] sovled 11b in 11a --- 2021/day11/11.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/2021/day11/11.py b/2021/day11/11.py index b8dc80c..5b95ca7 100644 --- a/2021/day11/11.py +++ b/2021/day11/11.py @@ -1,7 +1,9 @@ lines = [ [int(j) for j in list(i)] for i in open("input.txt", 'r').read().splitlines()] flashes = 0 -for i in range(100): +i = 0 +found = False +while i < 99 or not found: lines = [ [x+1 for x in y] for y in lines] flashed = True while flashed: @@ -9,7 +11,8 @@ for i in range(100): for x in range(10): for y in range(10): if lines[x][y] > 9: - flashes += 1 + if(i<100): + flashes += 1 lines[x][y] = 0 flashed = True if x != 0 and lines[x-1][y] != 0: @@ -28,5 +31,9 @@ for i in range(100): lines[x][y-1] += 1 if x != 0 and y != 0 and lines[x-1][y-1] != 0: lines[x-1][y-1] += 1 + i += 1 + if lines.count([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 10: + print(i) + found = True print(flashes) \ No newline at end of file