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: 12 }); | |
compute(2, async (input) => { | |
let data = input.parse(f.nl(f.dis(" ", f.str(), f.split(",", f.int()), (l, r) => ({ pat: l, segs: r })))); | |
data = data.map(({ pat, segs }) => ({ | |
pat: (pat + "?").repeat(5).slice(0, -1) + ".", | |
segs: segs.concat(segs, segs, segs, segs) |
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: 11 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.cGrid()); | |
let rows: number[] = []; |
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, mapGrid, neighbors } from "advent"; | |
import { Set, Map } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 10 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.cGrid()); | |
let startPosition: [number, number] = [0, 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: 7 }); | |
compute(2, async (input) => { | |
let data = input.parse(f.nl(f.dis(" ", f.str(), f.int(), (l, r) => [l, r]))) as [string, number][]; | |
data = data.sort(([a], [b]) => compare(a, b)); | |
console.log(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 } from "advent"; | |
import { Set, Map } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 6 }); | |
compute(2, async (input) => { | |
// Time: 61 70 90 66 | |
// Distance: 643 1184 1362 1041 | |
// const data = [ | |
// { time: 61, distance: 643 }, |
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, int } from "advent"; | |
import { Set, Map } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 5 }); | |
compute(2, async (input) => { | |
const seeds = input.all().split("\n")[0].split(": ")[1].split(" ").map(int); | |
console.log(seeds); | |
const maps = input.all().split("\n\n").slice(1).map((m) => { | |
const parts = m.split("\n").slice(1); |
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: 3 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.cGrid()); | |
let ans = 0; | |
let gearmap = Map<number, Map<number, number[]>>(); |
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: 22 }); | |
interface Face { | |
id: number; | |
x: number; | |
y: number; | |
top?: FaceAdj; |
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: 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 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, 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 |