library(adventofcode17)
input <-
"....##.#.#.#...#.##.##.#.
##.####..###..#.#.#.###.#
.#.#...#.##....#......###
...#.....##.###....##.###
#.########.#.#####..##.#.
.#..#..#.#..#....##.#...#
.....#.##..#.#.....##..##
....###....###....###.#..
..#..#..#..#.##.#.#..##.#
.##......#...##.#.#.##.#.
.#####.#.#.##...###...#..
#..###..#....#....##..#..
###..#....#.##.##.....#..
##.##..#.##.#..#####.#.#.
#....#.######.#.#.#.##.#.
###.##.#.######.#..###.#.
#...###.#.#..##..####....
###...##.###..###..##..#.
..##.###...#.....##.##.##
..##..#.###.###.....#.###
#..###.##.#.###......####
#.#...#..##.###.....##.#.
#..#.##...##.##....#...#.
..#.#..#..#...##.#..###..
......###....#.....#....#"
grid <- input %>% read_text_lines() %>% virus_grid()
grid$step(10000)
stopifnot(grid$get_infect_count() == aoc17_solutions$day22a)
# Part B takes forever!
seriously <- FALSE
if (seriously) {
grid <- input %>% read_text_lines() %>% evolved_virus_grid()
left <- 10000000
while (left > 0) {
if (left %% 100000 == 0) message(left)
grid$step(1000)
left <- left - 1000
}
stopifnot(grid$get_infect_count() == aoc17_solutions$day22b)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.