Browse Source

More waffle

master
Chris Smith 4 years ago
parent
commit
d4e4bd226b
Signed by: Chris Smith <chris@chameth.com> GPG Key ID: 3A2D4BBDC4A3C9A9
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      12/main.go

+ 8
- 4
12/main.go View File

72
 
72
 
73
 // Sweeping assumptions/notes on how this mess works:
73
 // Sweeping assumptions/notes on how this mess works:
74
 //
74
 //
75
-// 1) the movement of the planets will be parabolic - they'll accelerate towards each other,
75
+// 1) the movement of the moons will be parabolic - they'll accelerate towards each other,
76
 //    then gradually slow down to a complete stop and reverse path going back to the starting point.
76
 //    then gradually slow down to a complete stop and reverse path going back to the starting point.
77
 //    I'm not sure I can prove that's the case in general, but it does seem to hold true.
77
 //    I'm not sure I can prove that's the case in general, but it does seem to hold true.
78
 //
78
 //
79
-// 2) the middle of the parabola occurs after step 1000 (otherwise the code would need a fiddly bit of
79
+// 2) all the moons will hit the inflection point of the parabola at the same step. I think this is reasonable
80
+//    as each force is mirrored, so bodies accelerating towards one another will end up with the same total velocity
81
+//    when they cross
82
+//
83
+// 3) the middle of the parabola occurs after step 1000 (otherwise the code would need a fiddly bit of
80
 //    state tracking to ensure it returned a value for part 1).
84
 //    state tracking to ensure it returned a value for part 1).
81
 //
85
 //
82
-// 3) because the axes are independent, they can be simulated in parallel, and their individual parabolic inflection
86
+// 4) because the axes are independent, they can be simulated in parallel, and their individual parabolic inflection
83
 //    points found. This gives us the loop count for each axis (2x the number of steps to reach the inflection point),
87
 //    points found. This gives us the loop count for each axis (2x the number of steps to reach the inflection point),
84
 //    and we can find the first time all three axis's loops intersect by finding the lowest common multiple of those
88
 //    and we can find the first time all three axis's loops intersect by finding the lowest common multiple of those
85
 //    three values.
89
 //    three values.
88
 //
92
 //
89
 // <------------------- position on axis ------------------>
93
 // <------------------- position on axis ------------------>
90
 //
94
 //
91
-//                                                __,..--'""      |
95
+//                      (somewhere)               __,..--'""      |
92
 //                       step 1000       _,..--'""         ^      |
96
 //                       step 1000       _,..--'""         ^      |
93
 //                           v   _,..-'""                start    |
97
 //                           v   _,..-'""                start    |
94
 //                        _,..-'"                       vel = 0   |
98
 //                        _,..-'"                       vel = 0   |

Loading…
Cancel
Save