day 23 done B)
This commit is contained in:
parent
9a217a0202
commit
a847e4e73c
@ -1 +1 @@
|
|||||||
{"rustc_fingerprint":18427324047803895159,"outputs":{"12285253167677315500":{"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\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\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\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_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\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":{}}
|
{"rustc_fingerprint":18427324047803895159,"outputs":{"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":""},"12285253167677315500":{"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\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\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\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_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"apple\"\nunix\n","stderr":""}},"successes":{}}
|
@ -1 +1 @@
|
|||||||
{"rustc_fingerprint":18427324047803895159,"outputs":{"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":""},"12285253167677315500":{"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\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\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\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_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"apple\"\nunix\n","stderr":""}},"successes":{}}
|
{"rustc_fingerprint":18427324047803895159,"outputs":{"12285253167677315500":{"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\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\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\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_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\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":{}}
|
@ -1,13 +1,14 @@
|
|||||||
.^.
|
/^\
|
||||||
<#>
|
<#>
|
||||||
.v.
|
\v/
|
||||||
points + #
|
points + #
|
||||||
|
|
||||||
# = 7596
|
# = 7577
|
||||||
points + # = 34324
|
points + angles + # = 34324
|
||||||
|
|
||||||
..^..
|
|
||||||
./#\.
|
./^\.
|
||||||
|
/@#@\
|
||||||
<#@#>
|
<#@#>
|
||||||
.\#/.
|
.\#/.
|
||||||
..v..
|
..v..
|
||||||
|
8
day23/.idea/.gitignore
vendored
Normal file
8
day23/.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
day23/.idea/day23.iml
Normal file
11
day23/.idea/day23.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
day23/.idea/modules.xml
Normal file
8
day23/.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/day23.iml" filepath="$PROJECT_DIR$/.idea/day23.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
day23/.idea/vcs.xml
Normal file
6
day23/.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>
|
7
day23/Cargo.lock
generated
Normal file
7
day23/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "day23"
|
||||||
|
version = "0.1.0"
|
8
day23/Cargo.toml
Normal file
8
day23/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "day23"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
257
day23/src/main.rs
Normal file
257
day23/src/main.rs
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
use std::cmp::{max};
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
use std::fs;
|
||||||
|
use std::env;
|
||||||
|
use crate::Dir::{North, South, East, West};
|
||||||
|
|
||||||
|
// nodes are (coord, direction) pairs.
|
||||||
|
// neighbors are step1+turnleft, step2+turnleft, step3+turnleft, step1+turnright, etc
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||||
|
enum Dir { North, South, East, West }
|
||||||
|
|
||||||
|
fn step(start: &Coord, d: &Dir, steps: i32) -> Coord {
|
||||||
|
match d {
|
||||||
|
North => (start.0, start.1 - steps),
|
||||||
|
South => (start.0, start.1 + steps),
|
||||||
|
East => (start.0 + steps, start.1),
|
||||||
|
West => (start.0 - steps, start.1),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn slope_from_char(slope: &char) -> Option<Dir> {
|
||||||
|
match slope {
|
||||||
|
'>' => Some(East),
|
||||||
|
'<' => Some(West),
|
||||||
|
'v' => Some(South),
|
||||||
|
'^' => Some(North),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Coord = (i32, i32);
|
||||||
|
type Path = Vec<Coord>;
|
||||||
|
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, AoC day 17!");
|
||||||
|
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
if args.len() != 2 {
|
||||||
|
println!("wrong number of arguments!");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let file_path = &args[1];
|
||||||
|
|
||||||
|
let contents = fs::read_to_string(file_path).expect("Should have been able to read the file");
|
||||||
|
let mut grid: HashMap<Coord, char> = HashMap::new();
|
||||||
|
|
||||||
|
let mut start: Coord = (-1, -1);
|
||||||
|
let mut last: Coord = (-1, -1);
|
||||||
|
// build our grid!
|
||||||
|
let mut x = 0;
|
||||||
|
let mut y = 0;
|
||||||
|
for line in contents.lines() {
|
||||||
|
x = 0;
|
||||||
|
for c in line.chars() {
|
||||||
|
if y == 0 && c == '.' { start = (x,y); }
|
||||||
|
if c == '.' { last = (x,y); }
|
||||||
|
grid.insert((x,y), c);
|
||||||
|
x += 1;
|
||||||
|
}
|
||||||
|
y += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is this even necessary??
|
||||||
|
let mut walks: HashMap<Coord, char> = grid.clone();
|
||||||
|
for (key, value) in grid {
|
||||||
|
if value == '#' {
|
||||||
|
walks.remove(&key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for j in 0..y {
|
||||||
|
for i in 0..x {
|
||||||
|
if walks.contains_key(&(i,j)) {
|
||||||
|
print!("{}", walks.get(&(i,j)).unwrap());
|
||||||
|
} else {
|
||||||
|
print!(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print!("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut final_paths: HashSet<Path> = HashSet::new();
|
||||||
|
let mut heads: HashSet<(Coord, Path)> = HashSet::new();
|
||||||
|
heads.insert((start, Vec::from([start])));
|
||||||
|
while !heads.is_empty() {
|
||||||
|
let mut new_heads: HashSet<(Coord, Path)> = HashSet::new();
|
||||||
|
for (head, history) in &heads {
|
||||||
|
// take a step as each head.
|
||||||
|
if head == &last {
|
||||||
|
final_paths.insert(history.to_vec());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let neighbors = options(head, &walks);
|
||||||
|
let allowed_neighbors: Vec<&Coord> = neighbors.iter()
|
||||||
|
.filter(|candidate| !history.contains(candidate))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
for next_step in allowed_neighbors {
|
||||||
|
let mut next_history = history.clone();
|
||||||
|
next_history.push(head.clone());
|
||||||
|
new_heads.insert((*next_step, next_history));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
heads = new_heads;
|
||||||
|
}
|
||||||
|
println!("longest path following slopes is...");
|
||||||
|
println!("{}", final_paths
|
||||||
|
.iter()
|
||||||
|
.fold(0, |a: usize, b: &Path| max(a, b.len()))
|
||||||
|
);
|
||||||
|
println!("endopint i s {last:?}");
|
||||||
|
println!("now let's *not* follow some slopes. so first we want to build a more compact graph.");
|
||||||
|
let mut graph: HashMap<Coord, HashMap<Dir, (Coord, i32)>> = HashMap::new();
|
||||||
|
let mut unexplored: HashSet<Coord> = HashSet::from([start]);
|
||||||
|
while !unexplored.is_empty() {
|
||||||
|
// as long as we've got unexplored nodes to visit, we'll keep looping
|
||||||
|
let mut new_unexplored: HashSet<Coord> = HashSet::new();
|
||||||
|
for head in &unexplored {
|
||||||
|
if graph.contains_key(&head) {
|
||||||
|
// if we've already visited that location, skip it.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// otherwise it's new. so we add a record to our graph for it
|
||||||
|
let mut next_steps = HashMap::new();
|
||||||
|
for (direction, next) in options_but_free(&head, &walks) {
|
||||||
|
let (location, distance) = keep_going(&head, &next, &walks);
|
||||||
|
next_steps.insert(direction, (location, distance));
|
||||||
|
new_unexplored.insert(location);
|
||||||
|
}
|
||||||
|
graph.insert(*head, next_steps.clone());
|
||||||
|
|
||||||
|
println!("just explored location {head:?}, with outgoings {next_steps:?}");
|
||||||
|
}
|
||||||
|
unexplored = new_unexplored;
|
||||||
|
}
|
||||||
|
println!("graph has {} elements", graph.len());
|
||||||
|
|
||||||
|
println!("now let's do a breadth-first search, i guess. but it's going to be faster this time.");
|
||||||
|
let mut heads = HashSet::from([vec![(start, 0)]]);
|
||||||
|
let goal = last;
|
||||||
|
|
||||||
|
let mut full_paths = HashSet::new();
|
||||||
|
while heads.len() != 0 {
|
||||||
|
//step each head forward one time.
|
||||||
|
let mut new_heads = HashSet::new();
|
||||||
|
for path in &heads {
|
||||||
|
//println!("trying a path with {} steps", path.len());
|
||||||
|
let head = path.last().unwrap().0;
|
||||||
|
// check if we've reached an endpoint!
|
||||||
|
if goal == head {
|
||||||
|
full_paths.insert(path.to_vec());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// otherwise, look at each next step in the list:
|
||||||
|
for (_, (coord, distance)) in graph.get(&head).unwrap() {
|
||||||
|
if !fresh(coord, path) {
|
||||||
|
//println!("pruning a path!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let mut next_step_path = path.to_vec();
|
||||||
|
next_step_path.push((coord.clone(), distance.clone()));
|
||||||
|
new_heads.insert(next_step_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
heads = new_heads;
|
||||||
|
|
||||||
|
println!("heads has {} elements now", heads.len());
|
||||||
|
println!("maximum is {}", maxlength(&heads));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
println!("largest distance possible is {}", maxlength(&full_paths));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn maxlength(paths: &HashSet<Vec<(Coord, i32)>>) -> i32 {
|
||||||
|
let mut max_length = 0;
|
||||||
|
for full_path in paths {
|
||||||
|
let mut len = 0;
|
||||||
|
for (_, distance) in full_path {
|
||||||
|
len += distance;
|
||||||
|
}
|
||||||
|
if len > max_length {
|
||||||
|
max_length = len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return max_length;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fresh(step: &Coord, path: &Vec<(Coord, i32)>) -> bool {
|
||||||
|
for (location, _) in path {
|
||||||
|
if step == location {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn keep_going(from: &Coord, towards: &Coord, grid: &HashMap<Coord, char>) -> (Coord, i32) {
|
||||||
|
// receives where it comes from and where it's going towards.
|
||||||
|
// keeps walking towards where it's giong, until it reaches a branch, at which poiont it returns
|
||||||
|
// that coordinate and the distance it walked.
|
||||||
|
let mut seen = HashSet::from([from.clone()]);
|
||||||
|
let mut distance = 1;
|
||||||
|
let mut next = towards.clone();
|
||||||
|
loop {
|
||||||
|
let options = options_but_free(&next, grid);
|
||||||
|
if options.len() != 2 {
|
||||||
|
// if there's not two options available, then we're either at an endpoint or an intersection
|
||||||
|
// either way, we should break out and return (next,distance)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (_direction, step) in options {
|
||||||
|
//if we've already seen this upcoming spot, ignore it.
|
||||||
|
if seen.contains(&step) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
// otherwise increment distance, note the square we've been on, and step forward.
|
||||||
|
distance += 1;
|
||||||
|
seen.insert(next);
|
||||||
|
next = step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// now we've seen another one. register that.
|
||||||
|
}
|
||||||
|
return (next, distance);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn options(here: &Coord, grid: &HashMap<Coord, char>) -> Vec<Coord> {
|
||||||
|
let floor = grid.get(here).unwrap();
|
||||||
|
if let Some(must_go) = slope_from_char(floor) {
|
||||||
|
return Vec::from([four_winds(here).get(&must_go).unwrap().clone()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let steps = four_winds(here);
|
||||||
|
return steps.values().filter(|x| grid.contains_key(x)).copied().collect();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn options_but_free(here: &Coord, grid: &HashMap<Coord, char>) -> HashMap<Dir, Coord> {
|
||||||
|
let mut output:HashMap<Dir, Coord> = HashMap::with_capacity(4);
|
||||||
|
for (dir, next_step) in four_winds(here) {
|
||||||
|
if grid.contains_key(&next_step) { output.insert(dir, next_step); }
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn four_winds(here: &Coord) -> HashMap<Dir, Coord> {
|
||||||
|
return HashMap::from([
|
||||||
|
(North, step(here, &North, 1)),
|
||||||
|
(South, step(here, &South, 1)),
|
||||||
|
(East, step(here, &East, 1)),
|
||||||
|
(West, step(here, &West, 1))]);
|
||||||
|
}
|
1
day23/target/.rustc_info.json
Normal file
1
day23/target/.rustc_info.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"rustc_fingerprint":14318102787793507742,"outputs":{"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":""},"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":""}},"successes":{}}
|
3
day23/target/CACHEDIR.TAG
Normal file
3
day23/target/CACHEDIR.TAG
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Signature: 8a477f597d28d172789f06886806bc55
|
||||||
|
# This file is a cache directory tag created by cargo.
|
||||||
|
# For information about cache directory tags see https://bford.info/cachedir/
|
0
day23/target/debug/.cargo-lock
Normal file
0
day23/target/debug/.cargo-lock
Normal file
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
@ -0,0 +1 @@
|
|||||||
|
a7b0e4c9dd546fcf
|
@ -0,0 +1 @@
|
|||||||
|
{"rustc":4443399816165520464,"features":"[]","target":12078389660814236502,"profile":13053956386274884697,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/day23-08047b34a1a248d2/dep-test-bin-day23"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
@ -0,0 +1 @@
|
|||||||
|
b1bde777d9f2c21c
|
@ -0,0 +1 @@
|
|||||||
|
{"rustc":4443399816165520464,"features":"[]","target":12078389660814236502,"profile":13396965805329499462,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/day23-2555db558b3ab0aa/dep-bin-day23"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
@ -0,0 +1 @@
|
|||||||
|
d0c127dc560b99b1
|
@ -0,0 +1 @@
|
|||||||
|
{"rustc":4443399816165520464,"features":"[]","target":12078389660814236502,"profile":237655285757591511,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/day23-42a5522b767f966b/dep-bin-day23"}}],"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.
|
BIN
day23/target/debug/day23
Executable file
BIN
day23/target/debug/day23
Executable file
Binary file not shown.
1
day23/target/debug/day23.d
Normal file
1
day23/target/debug/day23.d
Normal file
@ -0,0 +1 @@
|
|||||||
|
/Users/shoofle/Projects/aoc_2023/day23/target/debug/day23: /Users/shoofle/Projects/aoc_2023/day23/src/main.rs
|
BIN
day23/target/debug/deps/day23-42a5522b767f966b
Executable file
BIN
day23/target/debug/deps/day23-42a5522b767f966b
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.
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.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user