aboutsummaryrefslogtreecommitdiffstats
path: root/src/12/part2
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-04-07 17:18:18 -0400
committerLouis Burda <quent.burda@gmail.com>2023-04-07 17:19:39 -0400
commit87ab487d59fa85dbe2afa55cc841b02805ae42ca (patch)
treecd90ab715e1b5b5803674045dbafd6d51d27ac90 /src/12/part2
parent1bcc82c5bfbde87edd03c01ffdf9ee5934681592 (diff)
downloadaoc2018-python-87ab487d59fa85dbe2afa55cc841b02805ae42ca.tar.gz
aoc2018-python-87ab487d59fa85dbe2afa55cc841b02805ae42ca.zip
Reorder days into src
Diffstat (limited to 'src/12/part2')
-rw-r--r--src/12/part249
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 the number of steps that must occur before all of the moons' positions and velocities
+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 very long time 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 find a more efficient way to simulate the universe.
+
+How many steps does it take to reach the first state that exactly matches a previous state?
+
+