Module aoc::year2019::day12

source ยท
Expand description

ยงThe N-Body Problem

There are two insights needed to solve part two:

  • Each axis is independent
  • Each axis is periodic somewhat like simple harmonic motion. The velocity returns to zero twice per period.

First find the period of each axis, then the answer is the least common multiple of all three combined.

The signum function comes in handy when updating the velocity.

Functionsยง

Type Aliasesยง