day8, example3 new approach
This commit is contained in:
29
day8/notes.org
Normal file
29
day8/notes.org
Normal file
@@ -0,0 +1,29 @@
|
||||
#+title: Notes
|
||||
* ok, for part 2 i think i'm supposed to find cicles.
|
||||
so for each starting point?
|
||||
calculate how long it takes to get to first Z, let's call is initialN
|
||||
and then how long it takes to get to Z again, call it cicleN
|
||||
|
||||
i have initial0 + n0 * cicle0 = k
|
||||
|
||||
now i need to find minimal number K ( steps ), so that exists solution for each starting point
|
||||
|
||||
(k - initial0) % cycle0 == 0
|
||||
|
||||
so. get both these numbers for each starting point.
|
||||
if initialN are equal, that's the answer.
|
||||
|
||||
if they are not equal?
|
||||
then i have what? huh
|
||||
|
||||
i guess then i need to add 1 cycle length to all.
|
||||
if they are equal, nice.
|
||||
|
||||
but if they are not equal?
|
||||
i guess i have one that's longest?
|
||||
then i need to advance all paths, up to and overshoot if necessary by their cycle lengths.
|
||||
so take the difference, if divisible by cycle - yay. just multiply, if not divisible - overshoot with +1 cycle
|
||||
|
||||
if all are same, that's solution.
|
||||
if one is farthest, repeat
|
||||
* i stopped bruteforce at 4080000000
|
||||
Reference in New Issue
Block a user