Advertisement
hhoppe

Advent of code 2023 day 24 part 2 concise

Dec 24th, 2023 (edited)
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. def day24_part2(s):
  2.   rows = [list(map(int, re.findall(r'[-\d]+', line))) for line in s.splitlines()]
  3.   p, v, ts = (sympy.symbols(f'{ch}(:3)') for ch in 'pvt')
  4.   equations = [
  5.       row[j] + t * row[3 + j] - p[j] - v[j] * t for row, t in zip(rows, ts) for j in range(3)
  6.   ]
  7.   return sum(sympy.solve(equations, (*p, *v, *ts))[0][:3])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement