From ee0c78709e3fbd5927774f55db3058018629cd30 Mon Sep 17 00:00:00 2001 From: setop Date: Fri, 6 Dec 2024 11:36:12 +0100 Subject: [PATCH] day 6: almost there for part 2 but no --- d06/part2.py | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 d06/part2.py diff --git a/d06/part2.py b/d06/part2.py new file mode 100644 index 0000000..cdf6592 --- /dev/null +++ b/d06/part2.py @@ -0,0 +1,114 @@ +import sys, os +from collections import Counter as C +from collections import defaultdict as dd + +""" +same convention as SVG + W +(0,0)┌───────────► x + │ + H │ + │ + │ + ▼ + y +grid G store list of rows +to get G(x,y), must first extract row y and then col y => G[y][x] +""" + +def grid_geom(G): + H = len(G) + W = len(G[0]) + return W, H + +def in_grid(G, x, y) -> bool: + W, H = grid_geom(G) + return x>=0 and x=0 and y