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: 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 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 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); |
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: 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 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 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 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 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 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 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[]>>(); |
NewerOlder