adventofcode/2023/04/test.js

24 lines
746 B
JavaScript
Raw Permalink Normal View History

2023-12-04 17:19:52 +00:00
import { test, expect } from "vitest";
import { readFileSync } from "fs-extra";
import { parse } from "yaml";
2023-12-04 15:03:46 +00:00
2023-12-04 17:19:52 +00:00
import { solution_1, slice_and_dice } from "./part1.js";
import { solution_2 } from "./part2.js";
2023-12-04 15:03:46 +00:00
2023-12-04 17:19:52 +00:00
const input = readFileSync("./input", { encoding: "utf8" });
const example = readFileSync("./example", { encoding: "utf8" });
const solutions = parse(readFileSync("./solutions.yml", { encoding: "utf8" }));
2023-12-04 15:03:46 +00:00
2023-12-04 17:19:52 +00:00
test("part 1", () => {
expect(
slice_and_dice("Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53")
).toBe(8);
2023-12-04 15:03:46 +00:00
2023-12-04 17:19:52 +00:00
expect(solution_1(example)).toBe(13);
expect(solution_1(input)).toBe(solutions["1"]);
});
test("part 2", () => {
expect(solution_2(example)).toBe(30);
expect(solution_2(input)).toBe(solutions["2"]);
});