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; |
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: 24 }); | |
// compute(1, async (input) => { | |
// const data = input.parse(f.dis("\n\n", f.nl(f.match`${fm.str().as("inp")}: ${fm.int().as("val")}`), f.nl(f.match`${fm.str().as("a")} ${fm.str().as("op")} ${fm.str().as("b")} -> ${fm.str().as("out")}`), (init, ops) => ({ init, ops }))); | |
// let refs = Map<string, Set<string>>(); | |
// let revRefs = Map<string, Set<string>>(); |
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, GridDirectionsWithoutDiagonals, mapGrid } from "advent"; | |
import { Set, Map, List } from "immutable"; | |
import PriorityQueue from "ts-priority-queue"; | |
// import { init } from "z3-solver"; | |
// const { Context } = await init(); | |
// const { Solver, Int, And } = Context("main"); | |
// const x = Int.const("x"); | |
// const solver = new Solver(); | |
// solver.add(And(x.ge(0), x.le(10))); |
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, arr } from "advent"; | |
import { Set, Map } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 19 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.dis("\n\n", f.split(", ", f.str()), f.nl(f.str()), (tow, targets) => ({ tow, targets }))); | |
let ans = 0; | |
// const regex = new RegExp("^(" + data.tow.map((rule) => `(${rule})`).join("|") + ")+$"); | |
// for (const target of data.targets) { |
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: 7 }); | |
compute(1, async (input) => { | |
const data = input.parse(f.nl(f.match`${fm.int().as("ans")}: ${fm.list(fm.int(), " ").as("deps")}`)); | |
let res = 0; | |
for (const { ans, deps } of data) { |
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, isDigit } from "advent"; | |
import { Set, Map } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 3 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.str()); | |
const regex = /mul\((\d+),(\d+)\)|do\(\)|don't\(\)/g; | |
let ok = true; |
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, isDigit } from "advent"; | |
import { Set, Map } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 1 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.nl(f.splitWs(f.int()))); | |
const arr1 = data.map((x) => x[0]); | |
const arr2 = data.map((x) => x[1]); | |
arr1.sort((a, b) => a - b); |
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, arr } from "advent"; | |
import { Set, Map } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 18 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.nl((s) => { | |
const [dir, dist, color] = s.split(" "); | |
// return { dir, dist: parseInt(dist), color }; | |
return { |
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"; | |
import { MinPriorityQueue } from "@datastructures-js/priority-queue"; | |
const { compute, computeCheck } = await Advent({ day: 17 }); | |
interface Location { | |
i: number; | |
j: number; | |
direction: number; // right, down, left, up |
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: 16 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.cGrid()); | |
let ans = 0; | |
for (let i = 0; i < data.length; i++) { | |
console.log(i); |
NewerOlder