wip
This commit is contained in:
parent
cea6397499
commit
335db26ad4
2 changed files with 32 additions and 34 deletions
|
|
@ -118,8 +118,8 @@ def svg(seen):
|
||||||
l = min(l, x)
|
l = min(l, x)
|
||||||
H = b - t + 1
|
H = b - t + 1
|
||||||
W = r - l + 1
|
W = r - l + 1
|
||||||
|
print(t, r, b, l)
|
||||||
im = Image.new(mode="RGB", size=(W,H), color=(255,255,255))
|
im = Image.new(mode="RGB", size=(W,H), color=(255,255,255))
|
||||||
print(H, "*", W)
|
|
||||||
for y, x in seen:
|
for y, x in seen:
|
||||||
im.putpixel((x-l, y-t), (0, 0, 0, 255))
|
im.putpixel((x-l, y-t), (0, 0, 0, 255))
|
||||||
im.save("aoc.png")
|
im.save("aoc.png")
|
||||||
|
|
|
||||||
|
|
@ -33,44 +33,42 @@ def solve(data):
|
||||||
break
|
break
|
||||||
S = E
|
S = E
|
||||||
# find out a better start for Flood fill by visualizing
|
# find out a better start for Flood fill by visualizing
|
||||||
Y = 1841
|
Y = 50000
|
||||||
X = 53478
|
X = 25000
|
||||||
# or, find a way to floodfill without BFS
|
# or, find a way to floodfill without BFS
|
||||||
# end
|
# end
|
||||||
y, x = Y, X
|
y, x = Y, X
|
||||||
Q = [(y, x)]
|
Q = [(y, x)]
|
||||||
V = V | B
|
V = V | B
|
||||||
print(len(B))
|
while Q:
|
||||||
svg(B)
|
yx = Q.pop()
|
||||||
# while Q:
|
if yx in V:
|
||||||
# yx = Q.pop()
|
continue
|
||||||
# if yx in V:
|
V.add(yx)
|
||||||
# continue
|
y, x = yx
|
||||||
# V.add(yx)
|
for dy, dx in D:
|
||||||
# y, x = yx
|
Q.append((dy + y, dx + x))
|
||||||
# for dy, dx in D:
|
for a, b in combinations(A, r=2):
|
||||||
# Q.append((dy + y, dx + x))
|
y1, x1 = a
|
||||||
# for a, b in combinations(A, r=2):
|
y2, x2 = b
|
||||||
# y1, x1 = a
|
x = abs(x1 - x2) + 1
|
||||||
# y2, x2 = b
|
y = abs(y1 - y2) + 1
|
||||||
# x = abs(x1 - x2) + 1
|
p1 = max(p1, x * y)
|
||||||
# y = abs(y1 - y2) + 1
|
if (
|
||||||
# p1 = max(p1, x * y)
|
len(
|
||||||
# if (
|
set(
|
||||||
# len(
|
[
|
||||||
# set(
|
(min(y1, y2), min(x1, x2)),
|
||||||
# [
|
(min(y1, y2), max(x1, x2)),
|
||||||
# (min(y1, y2), min(x1, x2)),
|
(max(y1, y2), min(x1, x2)),
|
||||||
# (min(y1, y2), max(x1, x2)),
|
(max(y1, y2), max(x1, x2)),
|
||||||
# (max(y1, y2), min(x1, x2)),
|
]
|
||||||
# (max(y1, y2), max(x1, x2)),
|
)
|
||||||
# ]
|
- V
|
||||||
# )
|
)
|
||||||
# - V
|
== 0
|
||||||
# )
|
):
|
||||||
# == 0
|
p2 = max(p2, max(p2, x * y))
|
||||||
# ):
|
|
||||||
# p2 = max(p2, max(p2, x * y))
|
|
||||||
return p1, p2
|
return p1, p2
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue