Cleanup 2024-25

This commit is contained in:
2024-12-25 11:42:01 +01:00
parent acd66b28ac
commit f3c4b5b7d5
+3 -5
View File
@@ -14,18 +14,16 @@ export function solveFirst(input: string): number {
(combinations, b) => { (combinations, b) => {
const rows = b.split('\n'); const rows = b.split('\n');
const isLock = b[0][0] === '#' ? 1 : 0; const isLock = b[0][0] === '#' ? 1 : 0;
const comb: KeyLock = []; const combination: KeyLock = [];
for (let i = 0; i < rows[0].length; i++) { for (let i = 0; i < rows[0].length; i++) {
const column = rows.flatMap((r) => r[i]); const column = rows.flatMap((r) => r[i]);
comb.push(column.filter((c) => c === '#').length - 1); combination.push(column.filter((c) => c === '#').length - 1);
} }
combinations[isLock].push(comb); combinations[isLock].push(combination);
return combinations; return combinations;
}, },
[[], []] as [KeyLock[], KeyLock[]] [[], []] as [KeyLock[], KeyLock[]]
); );
// const locks = blocks.filter((b) => b[0][0] === '#');
// const key = blocks.filter((b) => b[0][0] === '.');
const found = locks.map((l) => const found = locks.map((l) =>
sumBy(keys, (k) => (checkKeyLock(l, k) ? 1 : 0)) sumBy(keys, (k) => (checkKeyLock(l, k) ? 1 : 0))