Skip to content

Commit 340504a

Browse files
committed
Reorder part 2
1 parent 07a22db commit 340504a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/day7.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ fn search_part2(target: u64, v: &[NonZero<u64>]) -> bool {
8585
return false;
8686
}
8787

88-
if target % last == 0 {
89-
if search_part2(target / last, rest) {
88+
let size = unsafe { NonZero::new_unchecked(10u64.pow(last.ilog10() + 1)) };
89+
if (target - last) % size == 0 {
90+
if search_part2((target - last) / size, rest) {
9091
return true;
9192
}
9293
}
9394

94-
let size = unsafe { NonZero::new_unchecked(10u64.pow(last.ilog10() + 1)) };
95-
if (target - last) % size == 0 {
96-
if search_part2((target - last) / size, rest) {
95+
if target % last == 0 {
96+
if search_part2(target / last, rest) {
9797
return true;
9898
}
9999
}

0 commit comments

Comments
 (0)