day 10 part 1
This commit is contained in:
parent
bb03ac3dca
commit
2ee9c069d8
1 changed files with 17 additions and 2 deletions
|
@ -132,11 +132,26 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// we can't do this so we filter the broken ones away
|
||||||
|
let start = start.unwrap();
|
||||||
|
for (row_diff, col_diff) in [NORTH, EAST, SOUTH, WEST] {
|
||||||
|
let other = match (
|
||||||
|
start.row.checked_add_signed(row_diff),
|
||||||
|
start.col.checked_add_signed(col_diff)
|
||||||
|
) {
|
||||||
|
(Some(row), Some(col)) if row < grid.len() && col < grid[start.row].len() => {
|
||||||
|
Node { row, col }
|
||||||
|
},
|
||||||
|
_ => continue
|
||||||
|
};
|
||||||
|
if !adj.0[&other].contains(&start) {
|
||||||
|
adj.0.get_mut(&start).unwrap().remove(&other);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 6749 is too low
|
|
||||||
println!(
|
println!(
|
||||||
"{:?}",
|
"{:?}",
|
||||||
adj.dij(start.unwrap())
|
adj.dij(start)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.max_by_key(|(_, dist)| *dist)
|
.max_by_key(|(_, dist)| *dist)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
Loading…
Reference in a new issue