Function advent_solutions::advent2017::day22::part2_with_bursts
[−]
[src]
pub fn part2_with_bursts(input: &str, bursts: usize) -> usize
Start with the same map (still using . for clean and # for
infected) and still with the virus carrier starting in the middle and
facing up.
Using the same initial state as the previous example, and drawing
weakened as W and flagged as F, the middle of the infinite grid
looks like this, with the virus carrier's position again marked with
[ ]:
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . # . . .
. . . #[.]. . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
This is the same as before, since no initial nodes are weakened or flagged. The virus carrier is on a clean node, so it still turns left, instead weakens the node, and moves left:
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . # . . .
. . .[#]W . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
The virus carrier is on an infected node, so it still turns right, instead flags the node, and moves up:
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . .[.]. # . . .
. . . F W . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
This process repeats three more times, ending on the previously-flagged node and facing right:
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . W W . # . . .
. . W[F]W . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
Finding a flagged node, it reverses direction and cleans the node:
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . W W . # . . .
. .[W]. W . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
The weakened node becomes infected, and it continues in the same direction:
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . W W . # . . .
.[.]# . W . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
Of the first 100 bursts, 26 will result in infection.
Unfortunately, another feature of this evolved virus is speed; of the
first 10000000 bursts, 2511944 will result in infection.
let input = "..# #.. ... "; assert_eq!(part2_with_bursts(input, 100), 26); assert_eq!(part2_with_bursts(input, 10000000), 2511944);
Given your actual map, after 10000000 bursts of activity, how many
bursts cause a node to become infected? (Do not count nodes that begin
infected.)