37 lines
983 B
JavaScript
37 lines
983 B
JavaScript
import { test, expect, describe } from "vitest";
|
|
|
|
import { expectSolution } from "../01/main.js";
|
|
import part1, { sample, puzzleInput, isLessThan } from "./part1.js";
|
|
import part2 from "./part2.js";
|
|
|
|
describe("part 1", () => {
|
|
test("readInput", () => {
|
|
expect(sample[0][0]).toEqual([1, 1, 3, 1, 1]);
|
|
});
|
|
test("lessThan", () => {
|
|
expect(isLessThan(1, 2)).toBe(-1);
|
|
expect(isLessThan(2, 1)).toBe(1);
|
|
expect(isLessThan(2, 2)).toBe(0);
|
|
expect(isLessThan(2, [1])).toBe(1);
|
|
expect(isLessThan([1], [2])).toBe(-1);
|
|
});
|
|
test("sample", () => {
|
|
expect(part1(sample)).toEqual(13);
|
|
});
|
|
test("solution", () => {
|
|
const r = part1(puzzleInput);
|
|
expect(r).toBeGreaterThan(435);
|
|
expect(r).toBeLessThan(10980);
|
|
expectSolution(r).toEqual(5806);
|
|
});
|
|
});
|
|
|
|
describe("part 2", () => {
|
|
test("sample", () => {
|
|
expect(part2(sample)).toEqual(140);
|
|
});
|
|
test("solution", () => {
|
|
expectSolution(part2(puzzleInput)).toEqual(23600);
|
|
});
|
|
});
|