This commit is contained in:
Yanick Champoux 2022-12-03 16:32:41 -05:00
parent 86e03e8773
commit 33a11a02dd
3 changed files with 14 additions and 12 deletions

11
2022/01/main.js Normal file
View File

@ -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);
}

View File

@ -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));

View File

@ -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`;