File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 28
28
| [ Day 15: Warehouse Woes] ( src/solutions/year2024/day15.rs ) | ⭐⭐ | 7.226 | 9.084 |
29
29
| [ Day 16: Reindeer Maze] ( src/solutions/year2024/day16.rs ) | ⭐ | 6.478 | - |
30
30
| [ Day 17: Chronospatial Computer] ( src/solutions/year2024/day17.rs ) | - | - | - |
31
- | [ Day 18: RAM Run] ( src/solutions/year2024/day18.rs ) | ⭐⭐ | 2.487 | 379.772 |
31
+ | [ Day 18: RAM Run] ( src/solutions/year2024/day18.rs ) | ⭐⭐ | 2.487 | 204.885 |
32
32
| [ Day 19: Linen Layout] ( src/solutions/year2024/day19.rs ) | ⭐⭐ | 2.923 | 22.751 |
33
33
34
34
# 2023
Original file line number Diff line number Diff line change @@ -45,12 +45,16 @@ impl Solution for Day18 {
45
45
let start = self . surface . top_left_corner ( ) ;
46
46
let end = self . surface . bottom_right_corner ( ) ;
47
47
48
- let mut skipped: HashSet < Point > = byte_positions
48
+ let mut skipped = HashSet :: with_capacity ( byte_positions. len ( ) ) ;
49
+
50
+ let new: HashSet < Point > = byte_positions
49
51
. clone ( )
50
52
. into_iter ( )
51
53
. take ( self . memory_size )
52
54
. collect ( ) ;
53
55
56
+ skipped. extend ( new) ;
57
+
54
58
#[ allow( clippy:: needless_range_loop) ]
55
59
for i in self . memory_size ..byte_positions. len ( ) {
56
60
let current = byte_positions[ i] ;
@@ -80,8 +84,11 @@ impl Day18 {
80
84
}
81
85
82
86
fn is_reachable ( & self , blocked : & HashSet < Point > , start : Point , end : Point ) -> bool {
83
- let mut visited = HashSet :: new ( ) ;
84
- let mut queue = vec ! [ start] ;
87
+ let mut visited = HashSet :: with_capacity ( self . surface . area ( ) ) ;
88
+ let mut queue = Vec :: with_capacity ( self . surface . area ( ) ) ;
89
+
90
+ queue. push ( start) ;
91
+ visited. insert ( start) ;
85
92
86
93
while let Some ( current) = queue. pop ( ) {
87
94
if current == end {
You can’t perform that action at this time.
0 commit comments