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:
- Square
1starts with the value1. - Square
2has only one adjacent filled square (with value1), so it also stores1. - Square
3has both of the above squares as neighbors and stores the sum of their values,2. - Square
4has all three of the aforementioned squares as neighbors and stores the sum of their values,4. - Square
5only has the first and fourth squares as neighbors, so it gets the value5.
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()));