2022-12-15 19:35:55 +00:00
|
|
|
import { test, expect, describe } from "vitest";
|
|
|
|
|
|
|
|
import { expectSolution } from "../01/main.js";
|
|
|
|
import part1, { sample, puzzleInput, unbeaconAtLine } from "./part1.js";
|
2022-12-18 18:39:06 +00:00
|
|
|
import part2, { findBeacon } from "./part2.js";
|
2022-12-15 19:35:55 +00:00
|
|
|
|
|
|
|
describe("part 1", () => {
|
|
|
|
test('readInput', () => {
|
|
|
|
expect(sample[0][0].toArray()).toEqual([2, 18]);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('sample', () => {
|
|
|
|
expect(unbeaconAtLine(10)(sample)).toEqual(26);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("solution", () => {
|
|
|
|
expectSolution(part1(puzzleInput)).toEqual(5525990);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("part 2", () => {
|
2022-12-18 18:39:06 +00:00
|
|
|
test('sample', () => {
|
|
|
|
expect(findBeacon(20)(sample)).toEqual(56000011);
|
|
|
|
});
|
2022-12-18 21:06:07 +00:00
|
|
|
test("solution", () => {
|
|
|
|
// 314 seconds!
|
|
|
|
expectSolution(part2(puzzleInput)).toEqual(11756174628223);
|
2022-12-15 19:35:55 +00:00
|
|
|
});
|
|
|
|
});
|