This commit is contained in:
2021-12-16 16:46:55 +01:00
parent d9ae111b2c
commit 5704c6bd8d
5 changed files with 38 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ use std::io::prelude::*;
const RADIX: u32 = 10;
static mut shortest: u32 = 99999;
static mut shortest: u32 = 60000;
fn main(){
let file = File::open("./input.txt").expect("Read failed");
@@ -36,9 +36,9 @@ fn main(){
fn get_shortest_weight(weight_vec: &Vec<Vec<u32>>, x: usize, y: usize, current_weight: u32, width: usize, height: usize, visited: &Vec<(usize, usize)>) {
let mut visited_local = visited.to_owned();
unsafe {
if current_weight > shortest {
if visited_local.contains(&(x,y)) || current_weight > shortest || visited_local.len() > 1000{
//println!("Breaking at {}, {}, {}", current_weight, visited_local.len(), shortest);
return;
}
}
@@ -47,10 +47,6 @@ fn get_shortest_weight(weight_vec: &Vec<Vec<u32>>, x: usize, y: usize, current_w
println!("Current length: {}, shortest now: {}", current_weight, shortest);}
return;
}
if visited_local.contains(&(x,y)) {
return;
}
visited_local.push((x,y));
let temp_weight = current_weight + weight_vec[y][x];