Created
December 25, 2024 05:04
-
-
Save bluepichu/aec1ec7de46d8471e572e8985d123e65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Advent, f, fm, chr, ord } from "advent"; | |
import { Set, Map } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 25 }); | |
compute(1, async (input) => { | |
const data = input.parse(f.nnl(f.cGrid())); | |
const locks = data.filter((grid) => grid[0][0] === "#"); | |
const keys = data.filter((grid) => grid[0][0] === "."); | |
let ans = 0; | |
for (const l of locks) { | |
for (const k of keys) { | |
let ok = true; | |
for (let i = 0; i < data[0].length; i++) { | |
for (let j = 0; j < data[0][0].length; j++) { | |
if (l[i][j] === "#" && k[i][j] === "#") { | |
ok = false; | |
} | |
} | |
} | |
if (ok) { | |
ans++; | |
} | |
} | |
} | |
return ans; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment