adventofcode/2022/07/test.js

39 lines
953 B
JavaScript
Raw Normal View History

2022-12-07 23:43:09 +00:00
import { test, expect, describe } from "vitest";
import { expectSolution } from "../01/main.js";
2022-12-07 23:43:32 +00:00
import part1, { puzzleInput, sample, parseInput, cumulative } from "./part1.js";
import part2 from "./part2.js";
2022-12-07 23:43:09 +00:00
describe("part 1", () => {
2022-12-07 23:43:32 +00:00
const expected = { "/": 23352670, "/a": 94269, "/a/e": 584, "/d": 24933642 };
2022-12-07 23:43:09 +00:00
2022-12-07 23:43:32 +00:00
test("parseInput", () => {
const data = parseInput(sample);
2022-12-07 23:43:09 +00:00
2022-12-07 23:43:32 +00:00
expect(data).toEqual(expected);
});
2022-12-07 23:43:09 +00:00
2022-12-07 23:43:32 +00:00
test("cumulative", () => {
expect(cumulative(expected)).toEqual({
"/": 48381165,
"/a": 94853,
"/a/e": 584,
"/d": 24933642,
2022-12-07 23:43:09 +00:00
});
2022-12-07 23:43:32 +00:00
});
2022-12-07 23:43:09 +00:00
test("solution", () => {
expectSolution(part1(puzzleInput)).toEqual(1350966);
});
});
describe("part 2", () => {
test("sample", () => {
expect(part2(sample)).toEqual(24933642);
});
test("solution", () => {
expectSolution(part2(puzzleInput)).toBeLessThan(46647330);
expectSolution(part2(puzzleInput)).toEqual(6296435);
});
});