@@ -445,15 +445,12 @@ pub fn part2_inner(s: &[u8]) -> &'static str {
445445 } ;
446446
447447 let ( and1, xor1) = inputs[ 0 ] ;
448- let mut carry = if xor1 != ZSTART + 0 {
448+ if xor1 != ZSTART + 0 {
449449 // Asuming its a swap is with the carry
450450 debug_assert_eq ! ( and1, ZSTART ) ;
451451 // println!("Swaping start: {} - {}", tos(and1), tos(ZSTART));
452452 add_to_to_swap ( xor1, & mut to_swap) ;
453453 add_to_to_swap ( and1, & mut to_swap) ;
454- xor1
455- } else {
456- and1
457454 } ;
458455
459456 ' outer: for i in 1 ..45 {
@@ -474,7 +471,7 @@ pub fn part2_inner(s: &[u8]) -> &'static str {
474471 let next1 = gates. get_unchecked ( xor1 as usize ) . out_1 ;
475472 let next2 = gates. get_unchecked ( xor1 as usize ) . out_2 ;
476473
477- let or = if and1 == ZSTART + i {
474+ if and1 == ZSTART + i {
478475 add_to_to_swap ( ZSTART + i, & mut to_swap) ;
479476
480477 if gates. get_unchecked ( next1 as usize ) . state == State :: Xor {
@@ -487,29 +484,22 @@ pub fn part2_inner(s: &[u8]) -> &'static str {
487484 if to_swap. len ( ) == 8 {
488485 break ' outer;
489486 }
490-
491- // TODO: is it correct to asume this?
492- let or = gates. get_unchecked ( next1 as usize ) . out_1 ;
493- or
494487 } else {
495488 debug_assert_eq ! ( gates[ and1 as usize ] . out_2, 0 ) ;
496489 let or_from_and1 = gates. get_unchecked ( and1 as usize ) . out_1 ;
497490
498491 if or_from_and1 == ZSTART + i {
499492 add_to_to_swap ( ZSTART + i, & mut to_swap) ;
500- let or = if gates[ next1 as usize ] . state == State :: Xor {
493+ if gates[ next1 as usize ] . state == State :: Xor {
501494 add_to_to_swap ( next1, & mut to_swap) ;
502- next1
503495 } else if gates[ next2 as usize ] . state == State :: Xor {
504496 add_to_to_swap ( next2, & mut to_swap) ;
505- next2
506497 } else {
507498 unreachable_unchecked ( )
508499 } ;
509500 if to_swap. len ( ) == 8 {
510501 break ' outer;
511502 }
512- or
513503 } else {
514504 if gates. get_unchecked ( ( ZSTART + i) as usize ) . state != State :: Xor {
515505 add_to_to_swap ( next1, & mut to_swap) ;
@@ -518,16 +508,10 @@ pub fn part2_inner(s: &[u8]) -> &'static str {
518508 if to_swap. len ( ) == 8 {
519509 break ' outer;
520510 }
521-
522- or_from_and1
523511 }
524512 } ;
525-
526- carry = or;
527513 }
528514
529- // debug_assert_eq!(carry, ZSTART + 45);
530-
531515 to_swap. sort_unstable ( ) ;
532516 debug_assert_eq ! ( to_swap. len( ) , 8 ) ;
533517
0 commit comments