added skeleton for 16

This commit is contained in:
kageru 2018-12-17 09:45:54 +01:00
parent b54ce71339
commit 5ffbec2841
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2
5 changed files with 3960 additions and 66 deletions

View File

@ -1,66 +0,0 @@
Our sponsors help make Advent of Code possible:
Square - Join us and let's build the future of commerce!
--- Day 12: Subterranean Sustainability ---
The year 518 is significantly more underground than your history books implied. Either that, or you've arrived in a vast cavern network under the North Pole.
After exploring a little, you discover a long tunnel that contains a row of small pots as far as you can see to your left and right. A few of them contain plants - someone is trying to grow things in these geothermally-heated caves.
The pots are numbered, with 0 in front of you. To the left, the pots are numbered -1, -2, -3, and so on; to the right, 1, 2, 3.... Your puzzle input contains a list of pots from 0 to the right and whether they do (#) or do not (.) currently contain a plant, the initial state. (No other pots currently contain plants.) For example, an initial state of #..##.... indicates that pots 0, 3, and 4 currently contain plants.
Your puzzle input also contains some notes you find on a nearby table: someone has been trying to figure out how these plants spread to nearby pots. Based on the notes, for each generation of plants, a given pot has or does not have a plant based on whether that pot (and the two pots on either side of it) had a plant in the last generation. These are written as LLCRR => N, where L are pots to the left, C is the current pot being considered, R are the pots to the right, and N is whether the current pot will have a plant in the next generation. For example:
A note like ..#.. => . means that a pot that contains a plant but with no plants within two pots of it will not have a plant in it during the next generation.
A note like ##.## => . means that an empty pot with two plants on each side of it will remain empty in the next generation.
A note like .##.# => # means that a pot has a plant in a given generation if, in the previous generation, there were plants in that pot, the one immediately to the left, and the one two pots to the right, but not in the ones immediately to the right and two to the left.
It's not clear what these plants are for, but you're sure it's important, so you'd like to make sure the current configuration of plants is sustainable by determining what will happen after 20 generations.
For example, given the following input:
initial state: #..#.#..##......###...###
...## => #
..#.. => #
.#... => #
.#.#. => #
.#.## => #
.##.. => #
.#### => #
#.#.# => #
#.### => #
##.#. => #
##.## => #
###.. => #
###.# => #
####. => #
For brevity, in this example, only the combinations which do produce a plant are listed. (Your input includes all possible combinations.) Then, the next 20 generations will look like this:
1 2 3
0 0 0 0
0: ...#..#.#..##......###...###...........
1: ...#...#....#.....#..#..#..#...........
2: ...##..##...##....#..#..#..##..........
3: ..#.#...#..#.#....#..#..#...#..........
4: ...#.#..#...#.#...#..#..##..##.........
5: ....#...##...#.#..#..#...#...#.........
6: ....##.#.#....#...#..##..##..##........
7: ...#..###.#...##..#...#...#...#........
8: ...#....##.#.#.#..##..##..##..##.......
9: ...##..#..#####....#...#...#...#.......
10: ..#.#..#...#.##....##..##..##..##......
11: ...#...##...#.#...#.#...#...#...#......
12: ...##.#.#....#.#...#.#..##..##..##.....
13: ..#..###.#....#.#...#....#...#...#.....
14: ..#....##.#....#.#..##...##..##..##....
15: ..##..#..#.#....#....#..#.#...#...#....
16: .#.#..#...#.#...##...#...#.#..##..##...
17: ..#...##...#.#.#.#...##...#....#...#...
18: ..##.#.#....#####.#.#.#...##...##..##..
19: .#..###.#..#.#.#######.#.#.#..#.#...#..
20: .#....##....#####...#######....#.#..##.
The generation is shown along the left, where 0 is the initial state. The pot numbers are shown along the top, where 0 labels the center pot, negative-numbered pots extend to the left, and positive pots extend toward the right. Remember, the initial state begins at pot 0, which is not the leftmost pot used in this example.
After one generation, only seven plants remain. The one in pot 0 matched the rule looking for ..#.., the one in pot 4 matched the rule looking for .#.#., pot 9 matched .##.., and so on.
In this example, after 20 generations, the pots shown as # contain plants, the furthest left of which is pot -2, and the furthest right of which is pot 34. Adding up all the numbers of plant-containing pots after the 20th generation produces 325.
After 20 generations, what is the sum of the numbers of all pots which contain a plant?

7
16/Cargo.toml Normal file
View File

@ -0,0 +1,7 @@
[package]
name = "d16"
version = "0.1.0"
authors = ["kageru <kageru@encode.moe>"]
edition = "2018"
[dependencies]

3091
16/input Normal file

File diff suppressed because it is too large Load Diff

853
16/input2 Normal file
View File

@ -0,0 +1,853 @@
5 1 3 3
5 3 2 2
5 2 1 0
3 0 2 3
13 3 2 3
13 3 3 3
4 1 3 1
10 1 0 2
5 1 2 1
13 0 0 3
9 3 1 3
11 1 0 3
13 3 1 3
13 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3 1 1
5 1 1 0
5 2 1 3
5 0 2 2
14 2 3 2
13 2 3 2
4 2 1 1
5 1 3 3
5 3 2 2
5 2 0 0
0 0 3 2
13 2 2 2
4 2 1 1
5 2 2 3
5 0 0 2
5 0 3 0
14 2 3 0
13 0 3 0
4 0 1 1
5 3 3 3
5 3 0 0
15 0 2 3
13 3 1 3
4 1 3 1
5 0 2 3
5 2 0 2
5 2 2 0
2 3 2 2
13 2 3 2
4 2 1 1
10 1 0 0
5 3 0 1
5 2 3 3
5 0 3 2
15 1 2 3
13 3 1 3
4 3 0 0
10 0 3 2
5 2 1 0
13 1 0 3
9 3 2 3
7 0 1 1
13 1 2 1
4 2 1 2
5 3 3 3
5 3 2 0
5 2 0 1
8 0 1 3
13 3 3 3
4 2 3 2
10 2 3 3
5 1 0 2
5 3 3 1
5 2 0 0
15 1 2 1
13 1 1 1
13 1 2 1
4 3 1 3
5 1 0 0
5 3 0 2
5 3 2 1
15 1 2 2
13 2 2 2
4 2 3 3
10 3 0 1
5 0 1 3
13 1 0 2
9 2 2 2
2 3 2 0
13 0 2 0
4 0 1 1
10 1 3 0

9
16/src/main.rs Normal file
View File

@ -0,0 +1,9 @@
fn addi(first: i32, second: i32) -> i32 {
return first + second;
}
fn main() {
println!("Hello, world!");
let a: fn(i32, i32) -> i32 = addi;
println!("{}", a(1, 2));
}