adventofcode/2022/15/test.js

30 lines
791 B
JavaScript

import { test, expect, describe } from "vitest";
import { expectSolution } from "../01/main.js";
import part1, { sample, puzzleInput, unbeaconAtLine } from "./part1.js";
import part2, { findBeacon } from "./part2.js";
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", () => {
test('sample', () => {
expect(findBeacon(20)(sample)).toEqual(56000011);
});
test("solution", () => {
// 314 seconds!
expectSolution(part2(puzzleInput)).toEqual(11756174628223);
});
});