2022-12-02 15:59:27 +00:00
|
|
|
import { test, expect, describe } from "vitest";
|
2022-12-02 15:35:31 +00:00
|
|
|
|
2022-12-02 15:59:27 +00:00
|
|
|
import { expectSolution } from "../01/main.js";
|
|
|
|
import {
|
|
|
|
parseInput,
|
|
|
|
sampleInput,
|
|
|
|
puzzleInput,
|
|
|
|
mapScores,
|
|
|
|
solutionPart1,
|
|
|
|
} from "./part1.js";
|
|
|
|
import { solutionPart2 } from "./part2.js";
|
2022-12-02 15:35:31 +00:00
|
|
|
|
2022-12-02 15:59:27 +00:00
|
|
|
describe("part 1", () => {
|
|
|
|
test("input parsing", () => {
|
|
|
|
expect(parseInput(sampleInput)).toEqual([
|
|
|
|
["A", "Y"],
|
|
|
|
["B", "X"],
|
|
|
|
["C", "Z"],
|
|
|
|
]);
|
|
|
|
});
|
2022-12-02 15:35:31 +00:00
|
|
|
|
2022-12-02 15:59:27 +00:00
|
|
|
test("mapScore", () => {
|
|
|
|
expect(mapScores(["A", "B"])).toEqual([6, 2]);
|
|
|
|
expect(mapScores(["B", "A"])).toEqual([0, 1]);
|
|
|
|
expect(mapScores(["C", "C"])).toEqual([3, 3]);
|
|
|
|
});
|
2022-12-02 15:35:31 +00:00
|
|
|
|
2022-12-02 15:59:27 +00:00
|
|
|
test("part 1, sample", () => {
|
|
|
|
expect(solutionPart1(sampleInput)).toEqual(15);
|
|
|
|
});
|
2022-12-02 15:35:31 +00:00
|
|
|
|
2022-12-02 15:59:27 +00:00
|
|
|
test("solution", () => {
|
|
|
|
expectSolution(solutionPart1(puzzleInput)).toEqual(12458);
|
|
|
|
});
|
2022-12-02 15:35:31 +00:00
|
|
|
});
|
|
|
|
|
2022-12-02 15:59:27 +00:00
|
|
|
describe("part 2", () => {
|
|
|
|
test("part 2", () => {
|
|
|
|
expectSolution(solutionPart2(puzzleInput)).toEqual(12683);
|
|
|
|
});
|
2022-12-02 15:35:31 +00:00
|
|
|
});
|