Skip to content

Commit 27ea80c

Browse files
committed
Clean up day 13 solution a bit more
1 parent 1dc9e85 commit 27ea80c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

day13/src/day13.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
def solve(offset: np.ndarray) -> int:
2222
lcombs = [np.linalg.inv(m) @ (v + offset) for m, v in zip(mats, vecs)]
23-
return sum(int(np.sum(np.array([3, 1]) * np.round(lcomb))) for lcomb in lcombs if np.sum(np.abs(np.round(lcomb) - lcomb)) < 0.001)
23+
solvable = [np.round(lcomb).astype(int) for lcomb in lcombs if np.sum(np.abs(np.round(lcomb) - lcomb)) < 0.001]
24+
return sum(3 * lcomb[0] + lcomb[1] for lcomb in solvable)
2425

2526
print('Part 1:', solve(np.array([0, 0])))
2627
print('Part 2:', solve(10000000000000 * np.array([1, 1])))

0 commit comments

Comments
 (0)