Browse Source

tidy up

main
Yanick Champoux 6 months ago
parent
commit
e78cfbad07
  1. 0
      2022/01/input
  2. 11
      2022/01/main.js
  3. 12
      2022/01/test.js
  4. 3
      2022/02/part1.js

0
2022/input → 2022/01/input

11
2022/01/main.js

@ -0,0 +1,11 @@ @@ -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);
}

12
2022/01/test.js

@ -1,16 +1,14 @@ @@ -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( @@ -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));

3
2022/02/part1.js

@ -1,10 +1,7 @@ @@ -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`;

Loading…
Cancel
Save