projects
/
advent_of_code_2022.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3f40e06
)
Don't need to push visited position twice...
author
Greg Burri
<greg.burri@gmail.com>
Mon, 12 Dec 2022 09:47:58 +0000
(10:47 +0100)
committer
Greg Burri
<greg.burri@gmail.com>
Mon, 12 Dec 2022 09:47:58 +0000
(10:47 +0100)
src/day12.rs
patch
|
blob
|
history
diff --git
a/src/day12.rs
b/src/day12.rs
index
1e03ed3
..
ee08a24
100644
(file)
--- a/
src/day12.rs
+++ b/
src/day12.rs
@@
-52,6
+52,8
@@
pub fn nb_steps(hm: &Heightmap, path: Path) -> i32 {
positions
};
+ visited[hm.end.0][hm.end.1] = 0;
+
loop {
step = step + 1;
for (i, j) in positions.drain(..) {
@@
-59,7
+61,6
@@
pub fn nb_steps(hm: &Heightmap, path: Path) -> i32 {
return step;
}
- visited[i][j] = step;
for (ni, nj) in neighbors(i, j) {
if visited[ni][nj] == -1 && hm.elevations[i][j] - hm.elevations[ni][nj] <= 1 {
visited[ni][nj] = step;