adventofcode/2022/07/part2.js

21 lines
399 B
JavaScript

import * as R from "remeda";
import { cumulative, parseInput } from "./part1.js";
export default (lines) => {
let cumu = R.pipe(lines, parseInput, cumulative);
console.log(cumu);
const spaceNeeded = 30000000 - 70000000 + cumu["/"];
cumu = R.pickBy(cumu, (v) => v >= spaceNeeded);
return R.pipe(
R.keys(cumu),
R.sortBy((k) => cumu[k]),
R.first,
(k) => cumu[k]
);
};