Function advent_solutions::advent2017::day03::stress_test [] [src]

pub fn stress_test() -> impl Iterator<Item = usize>

As a stress test on the system, the programs here clear the grid and then store the value 1 in square 1. Then, in the same allocation order as shown above, they store the sum of the values in all adjacent squares, including diagonals.

So, the first few squares' values are chosen as follows:

Once a square is written, its value does not change. Therefore, the first few squares would receive the following values:

147  142  133  122   59
304    5    4    2   57
330   10    1    1   54
351   11   23   25   26
362  747  806--->   ...
let solution = [
    1usize, 1, 2, 4, 5, 10, 11, 23,
    25, 26, 54, 57, 59, 122, 133, 142,
    147, 304, 330, 351, 362, 747, 806,
];

assert!(stress_test().take(23).eq(solution.iter().cloned()));