mirror of
https://github.com/ershisan99/advent-of-code.git
synced 2025-12-17 04:59:27 +00:00
day 3
This commit is contained in:
43
day-3/day3.test.ts
Normal file
43
day-3/day3.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import * as path from "node:path";
|
||||
import { day3, day3part2 } from "./day3.ts";
|
||||
|
||||
test("day 3, part 1", async () => {
|
||||
const testInput = await Bun.file(
|
||||
path.resolve(__dirname, "test-input.txt"),
|
||||
).text();
|
||||
const input = await Bun.file(path.resolve(__dirname, "input.txt")).text();
|
||||
|
||||
const [testResult, finalResult] = await Promise.all([
|
||||
day3(testInput),
|
||||
day3(input),
|
||||
]);
|
||||
|
||||
console.log("\n\n");
|
||||
console.log("Test data:", testResult);
|
||||
console.log("Full data:", finalResult);
|
||||
console.log("\n\n");
|
||||
|
||||
expect(testResult).toEqual(161);
|
||||
expect(finalResult).toEqual(191183308);
|
||||
});
|
||||
|
||||
test("day 3, part 2", async () => {
|
||||
const testInput = await Bun.file(
|
||||
path.resolve(__dirname, "test-input.txt"),
|
||||
).text();
|
||||
const input = await Bun.file(path.resolve(__dirname, "input.txt")).text();
|
||||
|
||||
const [testResult, finalResult] = await Promise.all([
|
||||
day3part2(testInput),
|
||||
day3part2(input),
|
||||
]);
|
||||
|
||||
console.log("\n\n");
|
||||
console.log("Test data:", testResult);
|
||||
console.log("Full data:", finalResult);
|
||||
console.log("\n\n");
|
||||
|
||||
expect(testResult).toEqual(48);
|
||||
expect(finalResult).toEqual(92082041);
|
||||
});
|
||||
Reference in New Issue
Block a user