adventofcode/2022/13/test.js

37 lines
983 B
JavaScript
Raw Normal View History

2022-12-13 17:58:12 +00:00
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", () => {
2022-12-13 17:58:27 +00:00
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);
});
2022-12-13 17:58:12 +00:00
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);
});
});