finished day 3

This commit is contained in:
Adam "Touchdown dance" Kramer 2020-12-03 17:12:48 -08:00
parent 338920c64f
commit d2bfa9043e
123 changed files with 438 additions and 0 deletions

323
3.input Normal file
View File

@ -0,0 +1,323 @@
.##.#.........#.....#....#...#.
.#.#.#...#.......#.............
......#..#....#.#...###.......#
.......###......#.....#..##..#.
..#...##.......#.......###.....
....###.#....###......#....#..#
......#..#....#...##...........
..#..#....#...#.....####.......
...#........#.#.......#..#...#.
......#...#........#...#..##...
#..#........#............#...##
..#..#.#....#...........#...###
#.#..#...........#.##.#.#....#.
.#.#....#...##.....#...........
.....##....#...#..............#
...#....#...#.#.#.#...#........
#....#....#.#.#..#....#..#..#..
.................#..#.....#....
#..###...#.#..#.#......#.......
...#..........#......#....#....
.#.#.........##..#.......#...#.
.#..........#...#..#...........
....##.#.......................
.......#...........#...#.......
...#...#..##...#....###..#....#
....#.#.....##...##.#.#........
...........#.#..#.#......#..#..
.....#.....#....#...#........#.
..#......#..#.........#.....#..
.........................#...#.
#...#...#....#........##....#..
#..#.#.............#..........#
.#.........#.....#..#.#.#..#.#.
#...#..#.......####.#....##....
##...##..#.#.#...#.#.....#..#.#
.#..#....#.##........#...#....#
#...#..##.#....##..#..#.#......
.#........#.....#.#....##.##.#.
...#...#........#..#.##.##.....
....................#.#.#.#...#
..####.#..##...#....#.....##...
#......#.....#.#......#.#..#.##
..#.....#..#...........##.#....
#....#........#............#...
..##....#..............#......#
..#......#.#.......####......#.
..............##....#....##.#..
.#...............#....#....#.#.
..#.#.#..#.......##.#..........
.#...#.......#.#....#.##.......
.....#.##...#...........#.#....
..#.#..#...#..##...#.#.......##
.#.....#....#.#......#.#.......
....##.........#.#.............
.......##.......#..............
..........#......#......#....##
..##.....#..#.#..........#.....
...#....#.......#....##........
.......#...........#...........
...#.#......#.#........#....#..
.....#...........#.#.#...#.#..#
.#.#...#.#.#..........#.....###
#........#...#.................
...##.....#.....#..#..#.......#
......##...........#..#....##..
.........#............##...#...
.....#.....##...##.............
.#....#..#.#.#.#...#..#..#.....
.....#..#.#..#....#..#.........
....#.....#......#...#.........
#..#..#.................#......
.###.....#...#.#........##.#...
..#...#....#.##..#.....#.#....#
..#...##.................#.#...
....##..........#..#..#..#....#
....#..##....##.....#.#....#...
.#.#.#.....##........#.##..##.#
....#..#......#..#........#....
.......#.....###.#....#.......#
#....#.......#......##.#.......
.##.#.........#.#..##..#....##.
......#........#.#....#...#....
.####.....#.........#.#......##
##....#......#....#..#.#....##.
...........###.#.....#..#......
.......#...........#...........
........###....#..#.#..........
....#........#......#..........
.........#......#..............
...#...............#......#...#
....#..##...#.........#...#....
##........#.#....#......###....
....#.......................#..
#................#.#..#......##
...#.#.....#...#...........#.##
.#....#.##......#...##.#....#..
#...#....#..............#..#..#
.......#....#.##............#.#
.....#.#.......#.#...#.........
...#.....#..##...##...#........
..#.......#..####..#..#...#....
#.#................##...##.#..#
.....#.....##.#.....#......#..#
....#.#...#.........#.........#
..#......#............#.....#..
.....#..........#.#..#..##...##
........#................#.#...
#...#.#....##...###...#.#......
.............##.#..##..........
#..#......#...........#......#.
#.#....#..........#.##....###..
.............#.........#....#..
#........#..#.#..#...#....#....
..............#..............##
.....#...#..............#.##...
#...##..#...........#..........
..#....#...#.#........#..#.#..#
..##......#...............#....
....#...#..###..#......###.#...
.......##..#.#........#....#...
..##...#.......#...#...........
.#.......#.....#.#...##..#....#
.............#.......#.#.#....#
#.......#..#..#...#.#......##..
#.##..#..#..#....##.#...###.#.#
...##...#..#..#........#.#..#..
#....##........................
##...#...#......#.#.....#..#...
......#............#....#......
#......#.......#.......##.#....
..................#..#..#.#....
..#..................##.#......
..##........#.#.....##..#..#.#.
#....#..............#....####..
#..#..........................#
..#.#.#.#....#.......#....#.#..
.....#.#........#..........#.#.
........#.....#.......#........
#.....#....#.###.....#.......#.
.....##.#...#.#..#...#.#.#.....
......##...#.#...##..........#.
.#............#.....#..#....#..
.#................#.#..#.......
....................##...##....
#.......##...#.....#..#........
.##....#.#.#.#...........#...#.
..#.#..#.#.........#...........
...#......#.....#...##.........
..........#.#.....###.#........
.............#.....##..........
.........#...####........#.####
...................#....#......
.....#.........#.#....#..#...#.
.##...#.......##.#...#.#.#..#..
.....##........#....#...#.##.#.
#...#...#.#....#..............#
#..#.##.............#..........
..#...#..#.#.##..............##
#......#.#...##..........#.##..
.##.#...#...#.........#.#......
......#........##.#..#.........
#..#.......#......#.#..#.#.....
.#..#...........#.#.##.....#...
.....................#..#.#....
........#...##......#.....##...
#.............#...##....##....#
#.#...........#....##.#......##
.....#.....#.#..........###..#.
....#...#....##....#..##.......
.#....#....#.......#.#.....#...
.#...#.......##...##........#..
......##.......#.##.#.###......
....##.......#......#..........
...................#..##.......
......................#...##...
...##....#.#..#..#.............
.#......##..........#...#......
....##..#....#..#...#...####.#.
...#.......#.......#........#.#
#.........#..#...#...##...#.#.#
....#...#.......#...#....#.....
...#.....#.##..##.#.......##.##
.......#....#........#.........
.....#...#....#..#....#....#...
.##....#...#........#...#.#...#
.......##............#..#...#..
#.#...#....#......#.#..........
.#.##...........#........#.....
.#....#.............#.#.##.....
#.......###..#...###.........#.
#..#.#.......#.........#...#..#
..........#......#........#...#
.#.#...#.##.......##...........
.....#.........#.....#.........
.........#.........#....##.#..#
.#.......##..##..#.....#...#...
.#.....##...#..#..............#
..##...#..#..#.#...#..........#
.#.......####......#......####.
##..##........#.....#........#.
..##.#..#.#....................
...........#..#...##....##.....
..#.#........#.........#....##.
..#...#..##..###.#..###........
......#..#.............#..##...
.##.........#.#..#...#.##.###..
.#...............#...........#.
.#....#........#....#........##
..#####.#.#..#.#........##...#.
###....#....#...#..............
.....#...##............#...#...
##...........##.#.##.....#.....
..............#..#.....#...#...
...................#...........
#..........##.........#........
...#.........#..#.....#..#..#..
....###.#......#......##....#..
#......#..........#...#........
...#.#...#..#..........##......
.....##.....#.#............##..
..#..#.###....#.#.#...##....#..
...#........#....##.......#....
.#.............#..##.......#...
..#.#..###..#.....#...##.......
.........#......##...#.#..#....
.............#....##....#.#....
#..#...#....#.#...#......##....
.............#.#......#.....###
#.##....#........#.............
.....#...#.####...#.....#......
....#....###....##.......#.....
..#....##..#....#.#.......#....
...#.....#....#.........#......
.#......#.#....#.#........#....
.......#......#.....#.#..#.....
#......#.........##.##.#...#...
..#.###...................#....
....#..#....##.#........#....#.
...........#..........#......#.
.#..#.#...###..........#..#...#
...#...##..#....#...#..........
.#........#.................##.
....#.......##....#...#........
#.#...##.##...#.#.......#...#..
.....#.#.##.#......#..#..##....
.....##...#.#.....#...#........
#.#.......#..#..........##.....
................#......#..#.#.#
#......#...#...................
...#.....##.#.........#.#..#..#
...#..##..##.......#....#......
....##...#....#..#...........#.
..#..#......#...#..#...........
...#.##....#...##.......#......
.......#....#..#..##..#..#....#
.#.................#.#...#.##..
.....#..................#..#.#.
...#......##...#...........#...
..#.........#....#..#...#.....#
..#...#.....#.........##.#.....
.....#.#....##...............#.
....#...#............#.........
.....#.....###............#....
..#.#.#.......#....#...........
...........##...##...#.......#.
.........###.#......#..........
.#.......#....#.....#.##..#...#
..#..................#..###....
..#....#...#......##.........#.
........#..#........#.........#
.#..#......#.........#.........
...#..##.....#....#....#.....#.
......#.#............###.....##
.......#........#.......#.#....
..#.............#..............
.............##..#.#.#....#....
.................#....#.#......
##..#.#.......#....#.....#.....
.##............##.#.......#.#..
#..#...........##......#.......
.##......#####..##.#....#.#....
.......##.....#...#........#...
.#.#.....##....#..#....#..#...#
............##.#.....##.#......
........##...###.#......#......
......#..#.#...#..#............
.........#...........#......#..
.#.........#............##.....
.#..#..#...#.#.............#...
......#.#..##...#.#...........#
#.##.......#...#.........#.....
.....#..#............#....##...
.#......#........#.............
..#...#....#..#.......###......
....#.......###.#.#...........#
.............#...##............
.##.#.#.#...........#...#....#.
............##.........#......#
...............#......#...#....
...#.....#..###..#...........#.
.#........#.....##........#.#..
....#.#.......#..#..#...##.#.#.
.......##...........#...#......
....#.#..##......#.......#.....
..#........#.#......#.#........
........#....#..#....#..##.....
.#.........##..........#.#.....
..##...##.....##......##..#....
.###.....##...........##.#...##
...#................#.......#..
#.......#.#.#..#.#.##..#...#...
.#.#.......#..#................
..#.#.#......#............#....
#.....#.###..#.#...#...........
#...........#..........#.#.#.##
..#.#...#......##.....#........
........#.......#.#...#...#....
..#..........#......###......#.
..........##.#....#.....#.##...
..#.....#......#.........#..##.
.#...#........#..#.#..#...##..#
..###........#......#.#........
..#.##.#....#.#....#.#...#.....

0
src/bin/2.rs Normal file
View File

53
src/bin/3.rs Normal file
View File

@ -0,0 +1,53 @@
use std::fs::File;
use std::io::{BufRead, BufReader};
fn traverse(xslope: usize, yslope: usize, data: &Vec<Vec<bool>>) -> i64 {
let mut x = 0;
let mut y = 0;
let mut count = 0;
loop {
y += yslope;
x += xslope;
let row = data.get(y).unwrap();
if x >= row.len() {
x = x % row.len();
}
if row[x] {
count += 1;
}
if y == data.len() - 1 {
return count;
}
}
}
fn main() -> anyhow::Result<()> {
let file = File::open("3.input")?;
let reader = BufReader::new(file);
let mut data: Vec<Vec<bool>> = Vec::new();
for line in reader.lines() {
data.push(Vec::new());
let current_line = data.last_mut().unwrap();
for c in line?.chars() {
match c {
'#' => current_line.push(true),
'.' => current_line.push(false),
'\n' => (),
_ => panic!("unexpected input"),
}
}
}
println!("Count is {}", traverse(3, 1, &data));
let second = traverse(1, 1, &data) *
traverse(3, 1, &data) *
traverse(5, 1, &data) *
traverse(7, 1, &data) *
traverse(1, 2, &data);
println!("Second count is {}", second);
Ok(())
}

View File

@ -0,0 +1 @@
4a1a9d4c3bcf3173

View File

@ -0,0 +1 @@
{"rustc":1359611718356577327,"features":"[]","target":300061782397719604,"profile":18074012566298724745,"path":1808561760770030955,"deps":[[6716024485129112654,"anyhow",false,2153753142955884757]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/advent-50d3208384b478e2/dep-bin-3"}}],"rustflags":[],"metadata":16855462643986786377,"config":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
1394c88f1a6e65d3

View File

@ -0,0 +1 @@
{"rustc":1359611718356577327,"features":"[]","target":300061782397719604,"profile":8341259748240011191,"path":1808561760770030955,"deps":[[6716024485129112654,"anyhow",false,4012914409444696521]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/advent-657b4727d3d9d1d6/dep-test-bin-3"}}],"rustflags":[],"metadata":16855462643986786377,"config":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
23d32f59d997f35b

View File

@ -0,0 +1 @@
{"rustc":1359611718356577327,"features":"[]","target":12473694884668196228,"profile":8341259748240011191,"path":12686468793064529765,"deps":[[6716024485129112654,"anyhow",false,4012914409444696521]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/advent-7a0417601357c5ab/dep-test-bin-2"}}],"rustflags":[],"metadata":16855462643986786377,"config":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1,3 @@
{"message":"`main` function not found in crate `2`","code":{"code":"E0601","explanation":"No `main` function was found in a binary crate.\n\nTo fix this error, add a `main` function:\n\n```\nfn main() {\n // Your program will start here.\n println!(\"Hello world!\");\n}\n```\n\nIf you don't know the basics of Rust, you can look at the\n[Rust Book][rust-book] to get started.\n\n[rust-book]: https://doc.rust-lang.org/book/\n"},"level":"error","spans":[{"file_name":"src/bin/2.rs","byte_start":0,"byte_end":0,"line_start":0,"line_end":0,"column_start":1,"column_end":1,"is_primary":true,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider adding a `main` function to `src/bin/2.rs`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0601]\u001b[0m\u001b[0m\u001b[1m: `main` function not found in crate `2`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: consider adding a `main` function to `src/bin/2.rs`\u001b[0m\n\n"}
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to previous error\u001b[0m\n\n"}
{"message":"For more information about this error, try `rustc --explain E0601`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1mFor more information about this error, try `rustc --explain E0601`.\u001b[0m\n"}

View File

@ -0,0 +1 @@
a6e6d5b857e8d201

View File

@ -0,0 +1 @@
{"rustc":1359611718356577327,"features":"[]","target":300061782397719604,"profile":1613559695681135254,"path":1808561760770030955,"deps":[[6716024485129112654,"anyhow",false,4012914409444696521]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/advent-bd869b2eed552663/dep-bin-3"}}],"rustflags":[],"metadata":16855462643986786377,"config":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

BIN
target/debug/3 Executable file

Binary file not shown.

1
target/debug/3.d Normal file
View File

@ -0,0 +1 @@
/Users/adamkramer/advent/target/debug/3: /Users/adamkramer/advent/src/bin/3.rs

1
target/debug/3.dSYM Symbolic link
View File

@ -0,0 +1 @@
deps/3.dSYM

View File

@ -0,0 +1,5 @@
/Users/adamkramer/advent/target/debug/deps/2-7a0417601357c5ab.rmeta: src/bin/2.rs
/Users/adamkramer/advent/target/debug/deps/2-7a0417601357c5ab.d: src/bin/2.rs
src/bin/2.rs:

View File

@ -0,0 +1,5 @@
/Users/adamkramer/advent/target/debug/deps/2-87dd2d357b4f5ae0.rmeta: src/bin/2.rs
/Users/adamkramer/advent/target/debug/deps/2-87dd2d357b4f5ae0.d: src/bin/2.rs
src/bin/2.rs:

BIN
target/debug/deps/3 Executable file

Binary file not shown.

View File

@ -0,0 +1,5 @@
/Users/adamkramer/advent/target/debug/deps/3-657b4727d3d9d1d6.rmeta: src/bin/3.rs
/Users/adamkramer/advent/target/debug/deps/3-657b4727d3d9d1d6.d: src/bin/3.rs
src/bin/3.rs:

View File

@ -0,0 +1,5 @@
/Users/adamkramer/advent/target/debug/deps/3-bd869b2eed552663.rmeta: src/bin/3.rs
/Users/adamkramer/advent/target/debug/deps/3-bd869b2eed552663.d: src/bin/3.rs
src/bin/3.rs:

5
target/debug/deps/3.d Normal file
View File

@ -0,0 +1,5 @@
/Users/adamkramer/advent/target/debug/deps/3: src/bin/3.rs
/Users/adamkramer/advent/target/debug/deps/3.d: src/bin/3.rs
src/bin/3.rs:

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.3</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More