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", () => {
|
2023-11-30 15:13:16 +00:00
|
|
|
test("readInput", () => {
|
|
|
|
expect(sample[0][0].toArray()).toEqual([2, 18]);
|
|
|
|
});
|
2022-12-15 19:35:55 +00:00
|
|
|
|
2023-11-30 15:13:16 +00:00
|
|
|
test("sample", () => {
|
|
|
|
expect(unbeaconAtLine(10)(sample)).toEqual(26);
|
|
|
|
});
|
2022-12-15 19:35:55 +00:00
|
|
|
|
2023-11-30 15:13:16 +00:00
|
|
|
test("solution", () => {
|
|
|
|
expectSolution(part1(puzzleInput)).toEqual(5525990);
|
|
|
|
});
|
2022-12-15 19:35:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("part 2", () => {
|
2023-11-30 15:13:16 +00:00
|
|
|
test("sample", () => {
|
|
|
|
expect(findBeacon(20)(sample)).toEqual(56000011);
|
|
|
|
});
|
|
|
|
test("solution", () => {
|
|
|
|
// 314 seconds!
|
|
|
|
expectSolution(part2(puzzleInput)).toEqual(11756174628223);
|
|
|
|
});
|
2022-12-15 19:35:55 +00:00
|
|
|
});
|