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 { List, Map, Set } from "immutable"; | |
import { Advent, arr } from "advent"; | |
const { compute, computeCheck } = await Advent({ day: 20 }); | |
compute(async (input) => { | |
// const data = input.tokens(/,/).map(int); | |
const [alg, imageStr] = input.all().split("\n\n"); | |
let image = imageStr.split("\n").map((c) => c.split("")); | |
for (let i = 0; i < 50; 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 { List, Map, Set } from "immutable"; | |
import { Advent, int, arr } from "advent"; | |
const { compute, computeCheck } = await Advent({ day: 22 }); | |
interface Cube { | |
x1: number; | |
y1: number; | |
z1: number; | |
x2: 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
from z3 import * | |
with open("input.txt") as f: | |
lines = f.readlines() | |
iters = [] | |
for i in range(14): | |
base = i * 18 | |
print(lines[base + 4], lines[base + 5], lines[base + 15]) |
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, GridDirectionsWithoutDiagonals } from "advent"; | |
import { Set, Map } from "immutable"; | |
import * as p from "ts-priority-queue"; | |
const { compute, computeCheck } = await Advent({ day: 23 }); | |
interface Entry { | |
grid: string[][]; | |
cost: 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 } from "advent"; | |
const { compute, computeCheck } = await Advent({ day: 2 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.nl(f.tok(f.str()))); | |
let ans = 0; | |
for (const [them, us] of 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 { readFile, writeFile } from "fs/promises"; | |
import { join as pathJoin } from "path"; | |
import fetch from "node-fetch"; | |
import * as readline from "readline"; | |
const readlineInterface = readline.createInterface({ input: process.stdin, output: process.stdout }); | |
const session = (await readFile(pathJoin(process.env.HOME!, ".advent_cookie"))).toString().trim(); | |
export const int = (x: string): number => parseInt(x, 10); | |
export const num = (x: string): number => parseFloat(x); |
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 } from "advent"; | |
import { Set } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 3 }); | |
// compute(1, async (input) => { | |
// const data = input.parse(f.nl(f.chrs())); | |
// let ans = 0; | |
// for (const line of 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, arr, f } from "advent"; | |
import { Set, Map } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 5 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.nl(f.str())); | |
let stacks: string[][] = arr(9, () => []); | |
for (const line of data.slice(0, 8)) { |
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, ord } from "advent"; | |
import { Set, Map } from "immutable"; | |
const { compute, computeCheck } = await Advent({ day: 6 }); | |
compute(2, async (input) => { | |
const data = input.parse(f.str()); | |
for (let i = 0; i < data.length; i++) { | |
const slice = data.slice(i, i + 14); |
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 }; | |
} |