Skip to content

Commit

Permalink
perf(18/2024): optimize removing redundant cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
manhunto committed Dec 20, 2024
1 parent 9f20ee9 commit 5165099
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
| [Day 15: Warehouse Woes](src/solutions/year2024/day15.rs) | ⭐⭐ | 7.226 | 9.084 |
| [Day 16: Reindeer Maze](src/solutions/year2024/day16.rs) || 6.478 | - |
| [Day 17: Chronospatial Computer](src/solutions/year2024/day17.rs) | - | - | - |
| [Day 18: RAM Run](src/solutions/year2024/day18.rs) | ⭐⭐ | 2.487 | 431.665a |
| [Day 18: RAM Run](src/solutions/year2024/day18.rs) | ⭐⭐ | 2.487 | 379.772 |
| [Day 19: Linen Layout](src/solutions/year2024/day19.rs) | ⭐⭐ | 2.923 | 22.751 |

# 2023
Expand Down
10 changes: 2 additions & 8 deletions src/solutions/year2024/day18.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,8 @@ impl Day18 {
return true;
}

let neighbours: Vec<Point> = current
.adjacent()
.into_iter()
.filter(|p| !blocked.contains(p) && self.surface.contains(*p))
.collect();

for next in neighbours {
if visited.insert(next) {
for next in current.adjacent() {
if visited.insert(next) && self.surface.contains(next) && !blocked.contains(&next) {
queue.push(next);
}
}
Expand Down

0 comments on commit 5165099

Please sign in to comment.