diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-04-07 17:18:18 -0400 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-04-07 17:19:39 -0400 |
| commit | 87ab487d59fa85dbe2afa55cc841b02805ae42ca (patch) | |
| tree | cd90ab715e1b5b5803674045dbafd6d51d27ac90 /src/12/part2 | |
| parent | 1bcc82c5bfbde87edd03c01ffdf9ee5934681592 (diff) | |
| download | aoc2018-python-87ab487d59fa85dbe2afa55cc841b02805ae42ca.tar.gz aoc2018-python-87ab487d59fa85dbe2afa55cc841b02805ae42ca.zip | |
Reorder days into src
Diffstat (limited to 'src/12/part2')
| -rw-r--r-- | src/12/part2 | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/12/part2 b/src/12/part2 new file mode 100644 index 0000000..1fec84f --- /dev/null +++ b/src/12/part2 @@ -0,0 +1,49 @@ +--- Part Two --- + +All this drifting around in space makes you wonder about the nature of the universe. Does history +really repeat itself? You're curious whether the moons will ever return to a previous state. + +Determine [1m[97mthe number of steps[0m that must occur before all of the moons' [1m[97mpositions and velocities[0m +exactly match a previous point in time. + +For example, the first example above takes 2772 steps before they exactly match a previous point in +time; it eventually returns to the initial state: + +After 0 steps: +pos=<x= -1, y= 0, z= 2>, vel=<x= 0, y= 0, z= 0> +pos=<x= 2, y=-10, z= -7>, vel=<x= 0, y= 0, z= 0> +pos=<x= 4, y= -8, z= 8>, vel=<x= 0, y= 0, z= 0> +pos=<x= 3, y= 5, z= -1>, vel=<x= 0, y= 0, z= 0> + +After 2770 steps: +pos=<x= 2, y= -1, z= 1>, vel=<x= -3, y= 2, z= 2> +pos=<x= 3, y= -7, z= -4>, vel=<x= 2, y= -5, z= -6> +pos=<x= 1, y= -7, z= 5>, vel=<x= 0, y= -3, z= 6> +pos=<x= 2, y= 2, z= 0>, vel=<x= 1, y= 6, z= -2> + +After 2771 steps: +pos=<x= -1, y= 0, z= 2>, vel=<x= -3, y= 1, z= 1> +pos=<x= 2, y=-10, z= -7>, vel=<x= -1, y= -3, z= -3> +pos=<x= 4, y= -8, z= 8>, vel=<x= 3, y= -1, z= 3> +pos=<x= 3, y= 5, z= -1>, vel=<x= 1, y= 3, z= -1> + +After 2772 steps: +pos=<x= -1, y= 0, z= 2>, vel=<x= 0, y= 0, z= 0> +pos=<x= 2, y=-10, z= -7>, vel=<x= 0, y= 0, z= 0> +pos=<x= 4, y= -8, z= 8>, vel=<x= 0, y= 0, z= 0> +pos=<x= 3, y= 5, z= -1>, vel=<x= 0, y= 0, z= 0> + +Of course, the universe might last for a [1m[97mvery long time[0m before repeating. Here's a copy of the +second example from above: + +<x=-8, y=-10, z=0> +<x=5, y=5, z=10> +<x=2, y=-7, z=3> +<x=9, y=-8, z=-3> + +This set of initial positions takes 4686774924 steps before it repeats a previous state! Clearly, +you might need to [1m[97mfind a more efficient way to simulate the universe[0m. + +[1m[97mHow many steps does it take[0m to reach the first state that exactly matches a previous state? + + |
