File tree Expand file tree Collapse file tree 1 file changed +25
-10
lines changed
Expand file tree Collapse file tree 1 file changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -126,10 +126,11 @@ fn inner_part1(s: &[u8]) -> u64 {
126126 0
127127}
128128
129- pub fn part2 ( s : & str ) -> & str {
129+ #[ aoc( day18, part2) ]
130+ pub fn part2 ( s : & str ) -> String {
130131 #[ expect( unused_unsafe) ]
131132 unsafe {
132- inner_part2 ( s. as_bytes ( ) )
133+ inner_part2 ( s. as_bytes ( ) ) . to_owned ( )
133134 }
134135}
135136
@@ -356,14 +357,28 @@ fn inner_part2(s: &[u8]) -> &str {
356357 | ( map[ idx. wrapping_add ( SIZE1 as usize + 1 ) . min ( map. len ( ) - 1 ) ] as usize ) << 0 ;
357358
358359 let will_change = LUT [ luti] ;
359-
360- map[ y as usize * SIZE as usize + x as usize ] = true ;
361-
362- if will_change {
363- if !is_connected ( & map) {
364- return std:: str:: from_utf8 ( & s[ start_i..i - 1 ] ) . unwrap ( ) ;
365- }
360+ // dbg!(will_change);
361+
362+ map[ idx] = true ;
363+
364+ // if will_change {
365+ // for py in 0..SIZE {
366+ // for px in 0..SIZE {
367+ // if py == y as u32 && px == x as u32 {
368+ // print!("O");
369+ // } else if map[py as usize * SIZE1 as usize + px as usize] {
370+ // print!("#");
371+ // } else {
372+ // print!(".");
373+ // }
374+ // }
375+ // println!("");
376+ // }
377+ // println!("");
378+ if !is_connected ( & map) {
379+ return std:: str:: from_utf8 ( & s[ start_i..i - 1 ] ) . unwrap ( ) ;
366380 }
381+ // }
367382 }
368383}
369384
@@ -405,7 +420,7 @@ mod tests {
405420
406421 #[ test]
407422 fn example_part2 ( ) {
408- assert_eq ! ( part2( EXAMPLE ) , "6,1 " ) ;
423+ assert_eq ! ( part2( EXAMPLE ) , "" ) ;
409424 }
410425
411426 #[ test]
You can’t perform that action at this time.
0 commit comments