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