We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1dc9e85 commit 27ea80cCopy full SHA for 27ea80c
day13/src/day13.py
@@ -20,7 +20,8 @@
20
21
def solve(offset: np.ndarray) -> int:
22
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)
+ 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)
25
26
print('Part 1:', solve(np.array([0, 0])))
27
print('Part 2:', solve(10000000000000 * np.array([1, 1])))
0 commit comments