Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shahata committed Dec 24, 2024
1 parent e128e93 commit 5c89c41
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/2024/day24.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,16 @@ function extractUnit(gates, i) {
let not = gates
.filter(x => x.a === `x${next}` && x.b === `y${next}`)
.map(x => x.wire);
let wires = unit.map(x => x.wire);
let done = false;
while (!done) {
done = true;
let wires = unit.map(x => x.wire);
let more = gates.filter(x => wires.includes(x.a) || wires.includes(x.b));
more = more.filter(x => !unit.includes(x));
more = more.filter(x => !not.includes(x.a) && !not.includes(x.b));
if (more.length) {
done = false;
unit.push(...more);
wires.push(...more.map(x => x.wire));
}
}
return unit;
Expand Down

0 comments on commit 5c89c41

Please sign in to comment.