This file contains 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: 22 }); | |
interface Face { | |
id: number; | |
x: number; | |
y: number; | |
top?: FaceAdj; |
This file contains 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: 20 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.nl(f.int())).map((x) => x * 811589153); | |
let fwd = arr(data.length, (i) => i); | |
let bwd = arr(data.length, (i) => i); |
This file contains 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, ValueObject } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 18 }); | |
class Point implements ValueObject { | |
public constructor( | |
public x: number, | |
public y: number, | |
public z: number |
This file contains 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: 16 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.nl(f.match`Valve ${fm.word().as("name")} .* rate=${fm.int().as("rate")}; .* valves? ${fm.str().as("tunnelsStr")}`)); | |
let locs = Map(data.map((x) => [x.name, { rate: x.rate, tunnels: x.tunnelsStr.split(", ") }])); | |
let paths = Map<string, Map<string, number>>(); |
This file contains 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: 15 }); | |
computeCheck(2, async function*(input) { | |
const data = input.parse(f.nl(f.match`Sensor at x=${fm.int().as("sx")}, y=${fm.int().as("sy")}: closest .* x=${fm.int().as("bx")}, y=${fm.int().as("by")}`)); | |
// let endpoints: [number, boolean][] = []; | |
// const targetY = 2000000; |
This file contains 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: 14 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.nl(f.split(" -> ", f.split(",", f.int())))); | |
let ans = 0; | |
let used = Map<number, Set<number>>(); |
This file contains 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: 13 }); | |
// compute(1, async (input) => { | |
// const data = input.parse(f.nlnl(f.str())); | |
// let ans = 0; | |
// let i = 0; |
This file contains 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: 11 }); | |
interface Monkey { | |
items: number[]; | |
op: string; | |
test: number; | |
trueTarget: number; |
This file contains 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: 8 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.dGrid()); | |
let ans = 0; |
This file contains 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 }); | |
interface Dir { | |
parent?: Dir; | |
files: { [name: string]: number }; | |
dirs: { [name: string]: Dir }; | |
} |