From 33a11a02dded1d97b5ee52c6706e96cde5387b95 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Sat, 3 Dec 2022 16:32:41 -0500 Subject: [PATCH] tidy up --- 2022/01/main.js | 11 +++++++++++ 2022/01/test.js | 12 +++--------- 2022/02/part1.js | 3 --- 3 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 2022/01/main.js diff --git a/2022/01/main.js b/2022/01/main.js new file mode 100644 index 0000000..453167a --- /dev/null +++ b/2022/01/main.js @@ -0,0 +1,11 @@ +import { expect } from "vitest"; + +export const spy = (x) => { + console.debug(x); + return x; +}; + +export function expectSolution(result) { + console.info(result); + return expect(result); +} diff --git a/2022/01/test.js b/2022/01/test.js index a573612..7da2d97 100644 --- a/2022/01/test.js +++ b/2022/01/test.js @@ -1,16 +1,14 @@ import * as R from "remeda"; import { test, expect } from "vitest"; import fs from "fs-extra"; +import path from 'path'; +import { expectSolution } from './main.js'; const split = (splitter) => (text) => text.split(splitter); const sum = R.sumBy(R.identity); -const spy = (x) => { - console.debug(x); - return x; -}; const input = R.pipe( - fs.readFileSync("input", "utf8"), + fs.readFileSync( path.join( path.dirname(import.meta.url), "input").replace('file:',''), "utf8"), split("\n\n"), R.map((x) => split("\n")(x) @@ -20,10 +18,6 @@ const input = R.pipe( R.map(sum) ); -function expectSolution(result) { - console.info(result); - return expect(result); -} test("part 1", () => { const maxCalories = R.pipe(input, (calories) => Math.max(...calories)); diff --git a/2022/02/part1.js b/2022/02/part1.js index 7172837..2d3eb9c 100644 --- a/2022/02/part1.js +++ b/2022/02/part1.js @@ -1,10 +1,7 @@ import * as R from "remeda"; -import { test, expect } from "vitest"; import fs from "fs-extra"; import path from "path"; -import { spy } from "../01/main.js"; - export const sampleInput = `A Y B X C Z`;