Skip to content

Commit d5da1c2

Browse files
committed
Added plots
1 parent e834484 commit d5da1c2

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

aoc/2025/09/09.vn.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ def inter(self, ray):
5353
from tqdm.auto import tqdm
5454
from functools import cache
5555
from itertools import combinations
56+
import matplotlib.pyplot as plt
5657

5758

5859
xs = sorted(set(x for x, y in inp))
5960
ys = sorted(set(y for x, y in inp))
6061

61-
62+
original = inp
6263
inp = [(xs.index(x), ys.index(y)) for x, y in inp]
6364

6465
edges = []
@@ -120,4 +121,17 @@ def inside(p):
120121
if allIn:
121122
res2 = max(res2, area)
122123

123-
print(res1, res2)
124+
print(res1, res2)
125+
126+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(16, 8))
127+
128+
for i, (x, y) in enumerate(original):
129+
x2, y2 = original[(i+1) % len(original)]
130+
ax1.plot([x, x2], [y, y2], 'b-', marker='o')
131+
132+
for i, (x, y) in enumerate(inp):
133+
x2, y2 = inp[(i+1) % len(inp)]
134+
ax2.plot([x, x2], [y, y2], 'r-', marker='o')
135+
136+
137+
plt.show()

script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const PACKAGES_TO_LOAD = [
2121
// Common packages
2222
'numpy',
2323
// 'pandas',
24-
// 'matplotlib',
24+
'matplotlib',
2525
// 'scikit-learn',
2626
// 'scipy',
2727

0 commit comments

Comments
 (0)