From 5c89c41ee2b9b2faa52c6dfc80f3824c9a9d0c02 Mon Sep 17 00:00:00 2001 From: Shahar Talmi Date: Wed, 25 Dec 2024 01:11:26 +0200 Subject: [PATCH] minor fix --- src/2024/day24.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/2024/day24.js b/src/2024/day24.js index 0ca7f6b6..9c9b18d5 100644 --- a/src/2024/day24.js +++ b/src/2024/day24.js @@ -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;