Skip to content

Commit

Permalink
clean up old code where I stored the path for debugging purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
kcaffrey committed Dec 23, 2023
1 parent a50ec49 commit 22add1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ Solutions for [Advent of Code](https://adventofcode.com/) in [Rust](https://www.
| [Day 20](./src/bin/20.rs) | `323.9µs` | `1.2ms` |
| [Day 21](./src/bin/21.rs) | `64.1µs` | `494.7µs` |
| [Day 22](./src/bin/22.rs) | `78.3µs` | `194.8µs` |
| [Day 23](./src/bin/23.rs) | `329.1µs` | `72.6ms` |
| [Day 23](./src/bin/23.rs) | `328.8µs` | `69.4ms` |

**Total: 89.54ms**
**Total: 86.34ms**
<!--- benchmarking table --->

---
Expand Down
12 changes: 6 additions & 6 deletions src/bin/23.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ pub fn part_two(input: &str) -> Option<u16> {
goal = new_goal;
}

let mut visited = vec![None; graph.vertices];
visited[start] = Some(0);
let mut visited = vec![false; graph.vertices];
visited[start] = true;
Some(trimmed_length + part_two_recursive_brute_force(&graph, start, goal, &mut visited, 0))
}

fn part_two_recursive_brute_force(
graph: &Graph,
cur: usize,
goal: usize,
visited: &mut [Option<usize>],
visited: &mut [bool],
so_far: u16,
) -> u16 {
if cur == goal {
Expand All @@ -59,12 +59,12 @@ fn part_two_recursive_brute_force(

let mut max = 0;
for &(neighbor, cost) in &graph.adjacency[cur] {
if visited[neighbor].is_none() {
visited[neighbor] = Some(cur);
if !visited[neighbor] {
visited[neighbor] = true;
let next_so_far =
part_two_recursive_brute_force(graph, neighbor, goal, visited, so_far + cost);
max = max.max(next_so_far);
visited[neighbor] = None;
visited[neighbor] = false;
}
}

Expand Down

0 comments on commit 22add1b

Please sign in to comment.