Skip to content

Instantly share code, notes, and snippets.

View bluepichu's full-sized avatar

Matthew Savage bluepichu

View GitHub Profile
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;
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);
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
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>>();
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;
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>>();
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;
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;
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;
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 };
}