From 3c39e0e147a3ab6e7d1b845918f95748db44e149 Mon Sep 17 00:00:00 2001 From: setop Date: Thu, 8 Dec 2022 12:44:02 +0100 Subject: [PATCH] day 8, imperative way, ugly but works --- d08/part1.py | 17 +++++++++++++++++ d08/part2.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 d08/part1.py create mode 100644 d08/part2.py diff --git a/d08/part1.py b/d08/part1.py new file mode 100644 index 0000000..8ed3d06 --- /dev/null +++ b/d08/part1.py @@ -0,0 +1,17 @@ +import sys +L = list(list(map(int,s)) for s in sys.stdin.read().splitlines()) +W = len(L[0]) ; H = len(L) +N=0 +for i in range(H): + for j in range(W): + v = L[i][j] + # look right + r = all(L[i][k]=v: + break + # look left + l = 0 + for k in range(j-1,-1,-1): + l+=1 + if L[i][k]>=v: + break + # look up + u = 0 + for k in range(i-1,-1,-1): + u+=1 + if L[k][j]>=v: + break + # look down + d = 0 + for k in range(i+1,H): + d += 1 + if L[k][j]>=v: + break + S = max(S,r*l*u*d) +print(S)