From e51de70c36dc83f1623e5e8355f39e89ede50917 Mon Sep 17 00:00:00 2001 From: setop Date: Fri, 9 Dec 2022 00:06:28 +0100 Subject: [PATCH] day 8, compare two approaches for part 1 --- d08/part1.py | 6 ++++-- d08/part1b.py | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 d08/part1b.py diff --git a/d08/part1.py b/d08/part1.py index 8ed3d06..0bdafe1 100644 --- a/d08/part1.py +++ b/d08/part1.py @@ -1,7 +1,8 @@ import sys L = list(list(map(int,s)) for s in sys.stdin.read().splitlines()) W = len(L[0]) ; H = len(L) -N=0 +N = 0 +Q = 0 for i in range(H): for j in range(W): v = L[i][j] @@ -14,4 +15,5 @@ for i in range(H): # look down d = all(L[k][j] h: + V[r * W + c] = True + h = L[r][c] + Q += 1 + +V = [False for _ in range(size)] +for r in range(H): + check([r], range(W)) + check([r], range(W-1, -1, -1)) +for c in range(W): + check(range(H), [c]) + check(range(H-1, -1, -1), [c]) +print(sum(V), 2*(H*W+W*H), Q) \ No newline at end of file