diff --git a/2025-python/output/__init__.py b/2025-python/output/__init__.py index 06327c6..8a75109 100644 --- a/2025-python/output/__init__.py +++ b/2025-python/output/__init__.py @@ -118,8 +118,8 @@ def svg(seen): l = min(l, x) H = b - t + 1 W = r - l + 1 + print(t, r, b, l) 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") diff --git a/2025-python/output/day_09.py b/2025-python/output/day_09.py index b695247..9f27683 100644 --- a/2025-python/output/day_09.py +++ b/2025-python/output/day_09.py @@ -33,44 +33,42 @@ def solve(data): break S = E # find out a better start for Flood fill by visualizing - Y = 1841 - X = 53478 + Y = 50000 + X = 25000 # or, find a way to floodfill without BFS # end y, x = Y, X Q = [(y, x)] V = V | B - 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)) + 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