Skip to content

Commit

Permalink
refactor: Simplify exit condition on search
Browse files Browse the repository at this point in the history
  • Loading branch information
icyJoseph committed Dec 25, 2021
1 parent 8149c19 commit ed69f77
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions 2021/deno/day-24.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,8 @@ function search(
carry: number[],
range = allDigits
): number[] {
if (index === blocks.length - 1) {
for (const digit of range) {
// searching
if (execute_block(blocks[index], digit, z) === 0) {
return [...carry, digit];
}
}

return [];
if (index === blocks.length) {
return z === 0 ? carry : [];
}

let rng = range;
Expand Down

0 comments on commit ed69f77

Please sign in to comment.