Skip to content

Commit 07a22db

Browse files
committed
Make code work again
1 parent e896b59 commit 07a22db

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/day7.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ fn search(target: u64, v: &[NonZero<u64>]) -> bool {
77
[] => unsafe { unreachable_unchecked() },
88
[rest @ .., last] => {
99
let last = last.get();
10-
if last >= target || rest.is_empty() {
11-
return rest.is_empty() && last == target;
10+
if rest.is_empty() {
11+
return target == last;
1212
}
13+
if last > target {
14+
return false;
15+
}
16+
1317
if target % last == 0 {
1418
if search(target / last, rest) {
1519
return true;
@@ -74,9 +78,13 @@ fn search_part2(target: u64, v: &[NonZero<u64>]) -> bool {
7478
[] => unsafe { unreachable_unchecked() },
7579
[rest @ .., last] => {
7680
let last = last.get();
77-
if last >= target || rest.is_empty() {
78-
return rest.is_empty() && last == target;
81+
if rest.is_empty() {
82+
return target == last;
7983
}
84+
if last > target {
85+
return false;
86+
}
87+
8088
if target % last == 0 {
8189
if search_part2(target / last, rest) {
8290
return true;

0 commit comments

Comments
 (0)