Function advent_solutions::advent2017::day17::part1 [] [src]

pub fn part1(input: &usize) -> usize

For example, if the spinlock were to step 3 times per insert, the circular buffer would begin to evolve like this (using parentheses to mark the current position after each iteration of the algorithm):

And so on:

Eventually, after 2017 insertions, the section of the circular buffer near the last insertion looks like this:

1512  1134  151 (2017) 638  1513  851

Perhaps, if you can identify the value that will ultimately be after the last value written (2017), you can short-circuit the spinlock. In this example, that would be 638.

assert_eq!(part1(&3), 638)

What is the value after 2017 in your completed circular buffer?