diff --git a/2025-python/output/__init__.py b/2025-python/output/__init__.py
index c1861ff..06327c6 100644
--- a/2025-python/output/__init__.py
+++ b/2025-python/output/__init__.py
@@ -1,5 +1,6 @@
import re
from math import inf
+from PIL import Image
# Directions/Adjacents for 2D matrices, in the order UP, RIGHT, DOWN, LEFT
D = [
@@ -97,8 +98,40 @@ def vdbg(seen, mask=("#", "."), M=None):
C, Z = mask
def _m(r, c):
return M[r][c] if M else Z
+ O = []
for r in range(H):
- print("".join([C if (r + osr, c + osc) in seen else _m(r, c) for c in range(W)]))
+ O.append("".join([C if (r + osr, c + osc) in seen else _m(r, c) for c in range(W)]))
+ print("\n".join(O))
+
+
+def svg(seen):
+ """Print-debug visited positions of a matrix"""
+ t = inf
+ l = inf
+ b = 0
+ r = 0
+ rects = []
+ for y, x in seen:
+ t = min(t, y)
+ r = max(r, x)
+ b = max(b, y)
+ l = min(l, x)
+ H = b - t + 1
+ W = r - l + 1
+ im = Image.new(mode="RGB", size=(W,H), color=(255,255,255))
+ print(H, "*", W)
+ for y, x in seen:
+ im.putpixel((x-l, y-t), (0, 0, 0, 255))
+ im.save("aoc.png")
+
+ for y, x in seen:
+ rects.append(f"")
+ with open("svg.svg", "w") as f:
+ f.write(f"""
+
+ """.strip())
def vvdbg(seen, h, w):
diff --git a/2025-python/output/day_09.py b/2025-python/output/day_09.py
index 844d437..b695247 100644
--- a/2025-python/output/day_09.py
+++ b/2025-python/output/day_09.py
@@ -1,6 +1,7 @@
from itertools import combinations
+import PIL
-from output import ints
+from output import svg, D, ints, vdbg
def solve(data):
@@ -11,7 +12,6 @@ def solve(data):
S = A[0]
V = set()
B = set()
-
while True:
V.add(S)
y, x = S
@@ -40,35 +40,37 @@ def solve(data):
y, x = Y, X
Q = [(y, x)]
V = V | B
- while Q:
- yx = Q.pop()
- if yx in V:
- continue
- V.add(yx)
- y, x = yx
- for dy, dx in D:
- Q.append((dy + y, dx + x))
- for a, b in combinations(A, r=2):
- y1, x1 = a
- y2, x2 = b
- x = abs(x1 - x2) + 1
- y = abs(y1 - y2) + 1
- p1 = max(p1, x * y)
- if (
- len(
- set(
- [
- (min(y1, y2), min(x1, x2)),
- (min(y1, y2), max(x1, x2)),
- (max(y1, y2), min(x1, x2)),
- (max(y1, y2), max(x1, x2)),
- ]
- )
- - V
- )
- == 0
- ):
- p2 = max(p2, max(p2, x * y))
+ print(len(B))
+ svg(B)
+ # while Q:
+ # yx = Q.pop()
+ # if yx in V:
+ # continue
+ # V.add(yx)
+ # y, x = yx
+ # for dy, dx in D:
+ # Q.append((dy + y, dx + x))
+ # for a, b in combinations(A, r=2):
+ # y1, x1 = a
+ # y2, x2 = b
+ # x = abs(x1 - x2) + 1
+ # y = abs(y1 - y2) + 1
+ # p1 = max(p1, x * y)
+ # if (
+ # len(
+ # set(
+ # [
+ # (min(y1, y2), min(x1, x2)),
+ # (min(y1, y2), max(x1, x2)),
+ # (max(y1, y2), min(x1, x2)),
+ # (max(y1, y2), max(x1, x2)),
+ # ]
+ # )
+ # - V
+ # )
+ # == 0
+ # ):
+ # p2 = max(p2, max(p2, x * y))
return p1, p2