days 16 through 19 i think
This commit is contained in:
parent
9cc7b1a890
commit
02452722bf
8
day16/.idea/.gitignore
vendored
Normal file
8
day16/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
11
day16/.idea/day16.iml
Normal file
11
day16/.idea/day16.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="EMPTY_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
8
day16/.idea/modules.xml
Normal file
8
day16/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/day16.iml" filepath="$PROJECT_DIR$/.idea/day16.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
day16/.idea/vcs.xml
Normal file
6
day16/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -34,21 +34,7 @@ fn main() {
|
||||
}
|
||||
|
||||
//print_map(&g);
|
||||
|
||||
let visited = &mut HashSet::<Record>::new();
|
||||
trace(&g, visited, 0,0, 1,0);
|
||||
|
||||
|
||||
let mut sum = 0;
|
||||
for (x, y, _, _) in visited.iter() {
|
||||
if v[*y as usize][*x as usize] == '#' {
|
||||
continue;
|
||||
}
|
||||
v[*y as usize][*x as usize] = '#';
|
||||
sum += 1
|
||||
}
|
||||
|
||||
//print_map(&v);
|
||||
let sum = count(&g, (0,0,1,0));
|
||||
println!("totally marked off {sum} locations when entering from the upper left going right");
|
||||
|
||||
let mut maximum = 0;
|
||||
@ -60,19 +46,16 @@ fn main() {
|
||||
}
|
||||
|
||||
for y in 0..g.len() {
|
||||
let from_the_left = count(&g,
|
||||
(0, y as i32,
|
||||
1, 0));
|
||||
let from_the_left = count(&g, (0, y as i32, 1, 0));
|
||||
if from_the_left > maximum { maximum = from_the_left; }
|
||||
let from_the_right = count(&g,
|
||||
(g[0].len() as i32, y as i32,
|
||||
-1, 0));
|
||||
let from_the_right = count(&g, (g[0].len() as i32, y as i32, -1, 0));
|
||||
if from_the_right > maximum { maximum = from_the_right; }
|
||||
}
|
||||
|
||||
println!("the highest number of locations we could visit was {maximum}");
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn print_map(mat: &Vec<Vec<char>>) {
|
||||
for row in mat {
|
||||
for c in row {
|
||||
@ -84,33 +67,30 @@ fn print_map(mat: &Vec<Vec<char>>) {
|
||||
|
||||
fn trace(mat: &Vec<Vec<char>>,
|
||||
visited: &mut HashSet<Record>,
|
||||
start_x: i32,
|
||||
start_y: i32,
|
||||
start_dx: i32,
|
||||
start_dy: i32) -> () {
|
||||
start: Record) -> () {
|
||||
|
||||
let mut cx = start_x;
|
||||
let mut cy = start_y;
|
||||
let mut dx = start_dx;
|
||||
let mut dy = start_dy;
|
||||
let mut cx = start.0;
|
||||
let mut cy = start.1;
|
||||
let mut dx = start.2;
|
||||
let mut dy = start.3;
|
||||
|
||||
while cy >= 0 && (cy as usize) < mat.len() && cx >= 0 && (cx as usize) < mat[0].len() {
|
||||
if visited.contains(&(cx, cy, dx, dy)) { return (); }
|
||||
visited.insert((cx, cy, dx, dy));
|
||||
if visited.contains(&start) { return (); }
|
||||
visited.insert(start);
|
||||
|
||||
match mat[cy as usize][cx as usize] {
|
||||
'\\' => (dx, dy) = (dy, dx),
|
||||
'/' => (dx, dy) = (-dy, -dx),
|
||||
'|' =>
|
||||
if dx != 0 {
|
||||
trace(mat, visited, cx, cy, 0, 1);
|
||||
trace(mat, visited, cx, cy, 0, -1);
|
||||
trace(mat, visited, (cx, cy, 0, 1));
|
||||
trace(mat, visited, (cx, cy, 0, -1));
|
||||
return;
|
||||
},
|
||||
'-' =>
|
||||
if dy != 0 {
|
||||
trace(mat, visited, cx, cy, 1, 0);
|
||||
trace(mat, visited, cx, cy, -1, 0);
|
||||
trace(mat, visited, (cx, cy, 1, 0));
|
||||
trace(mat, visited, (cx, cy, -1, 0));
|
||||
return;
|
||||
},
|
||||
_ => ()
|
||||
@ -123,7 +103,7 @@ fn trace(mat: &Vec<Vec<char>>,
|
||||
|
||||
fn count(mat: &Vec<Vec<char>>, start: Record) -> i32 {
|
||||
let mut visit_set = HashSet::<Record>::new();
|
||||
trace(mat, &mut visit_set, start.0, start.1, start.2, start.3);
|
||||
trace(mat, &mut visit_set, start);
|
||||
|
||||
let mut v = Vec::<Vec<char>>::new();
|
||||
for row in mat {
|
||||
|
@ -1 +1 @@
|
||||
{"rustc_fingerprint":11672801278650259402,"outputs":{"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/shoofle/.rustup/toolchains/stable-x86_64-apple-darwin\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_feature=\"ssse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.69.0 (84c898d65 2023-04-16)\nbinary: rustc\ncommit-hash: 84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc\ncommit-date: 2023-04-16\nhost: x86_64-apple-darwin\nrelease: 1.69.0\nLLVM version: 15.0.7\n","stderr":""}},"successes":{}}
|
||||
{"rustc_fingerprint":14318102787793507742,"outputs":{"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/shoofle/.rustup/toolchains/stable-x86_64-apple-darwin\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_feature=\"sse4.1\"\ntarget_feature=\"ssse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.74.1 (a28077b28 2023-12-04)\nbinary: rustc\ncommit-hash: a28077b28a02b92985b3a3faecf92813155f1ea1\ncommit-date: 2023-12-04\nhost: x86_64-apple-darwin\nrelease: 1.74.1\nLLVM version: 17.0.4\n","stderr":""}},"successes":{}}
|
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
@ -0,0 +1 @@
|
||||
71b09de1aded0212
|
@ -0,0 +1 @@
|
||||
{"rustc":4443399816165520464,"features":"[]","target":250502024769020866,"profile":13053956386274884697,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/day16-03900f28025d4c7f/dep-test-bin-day16"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
@ -0,0 +1 @@
|
||||
2137fc3fa44ab9f3
|
@ -0,0 +1 @@
|
||||
{"rustc":4443399816165520464,"features":"[]","target":250502024769020866,"profile":237655285757591511,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/day16-5b74b45d1b6bc92c/dep-bin-day16"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
@ -0,0 +1 @@
|
||||
297e92fdabd39aaf
|
@ -0,0 +1 @@
|
||||
{"rustc":3659767333214291318,"features":"[]","target":250502024769020866,"profile":17483045194147818835,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/day16-7763588c3a64e881/dep-bin-day16"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
@ -0,0 +1 @@
|
||||
e9e854068db64f0a
|
@ -0,0 +1 @@
|
||||
{"rustc":4443399816165520464,"features":"[]","target":250502024769020866,"profile":13396965805329499462,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/day16-886360bced410ea3/dep-bin-day16"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
@ -1,2 +0,0 @@
|
||||
{"message":"function `print_map` is never used","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":2010,"byte_end":2019,"line_start":76,"line_end":76,"column_start":4,"column_end":13,"is_primary":true,"text":[{"text":"fn print_map(mat: &Vec<Vec<char>>) {","highlight_start":4,"highlight_end":13}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(dead_code)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: function `print_map` is never used\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:76:4\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m76\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0mfn print_map(mat: &Vec<Vec<char>>) {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^^^^^\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: `#[warn(dead_code)]` on by default\u001b[0m\n\n"}
|
||||
{"message":"1 warning emitted","code":null,"level":"warning","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: 1 warning emitted\u001b[0m\n\n"}
|
@ -1,2 +0,0 @@
|
||||
{"message":"function `print_map` is never used","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":2010,"byte_end":2019,"line_start":76,"line_end":76,"column_start":4,"column_end":13,"is_primary":true,"text":[{"text":"fn print_map(mat: &Vec<Vec<char>>) {","highlight_start":4,"highlight_end":13}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(dead_code)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: function `print_map` is never used\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:76:4\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m76\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0mfn print_map(mat: &Vec<Vec<char>>) {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^^^^^\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: `#[warn(dead_code)]` on by default\u001b[0m\n\n"}
|
||||
{"message":"1 warning emitted","code":null,"level":"warning","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: 1 warning emitted\u001b[0m\n\n"}
|
Binary file not shown.
BIN
day16/target/debug/deps/day16-5b74b45d1b6bc92c
Executable file
BIN
day16/target/debug/deps/day16-5b74b45d1b6bc92c
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5
day16/target/debug/deps/day16-5b74b45d1b6bc92c.d
Normal file
5
day16/target/debug/deps/day16-5b74b45d1b6bc92c.d
Normal file
@ -0,0 +1,5 @@
|
||||
/Users/shoofle/Projects/aoc_2023/day16/target/debug/deps/day16-5b74b45d1b6bc92c: src/main.rs
|
||||
|
||||
/Users/shoofle/Projects/aoc_2023/day16/target/debug/deps/day16-5b74b45d1b6bc92c.d: src/main.rs
|
||||
|
||||
src/main.rs:
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user