Skip to content

Instantly share code, notes, and snippets.

@bluepichu
Created December 25, 2024 05:04
Show Gist options
  • Save bluepichu/aec1ec7de46d8471e572e8985d123e65 to your computer and use it in GitHub Desktop.
Save bluepichu/aec1ec7de46d8471e572e8985d123e65 to your computer and use it in GitHub Desktop.
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