import * as R from "remeda"; const overlapsWith = ([a1, a2], [b1, b2]) => a2 >= b1; export const solutionPart2 = R.createPipe( (text) => text.split("\n"), R.filter(R.identity), R.map((line) => line.split(",").map((range) => range.split("-").map((x) => parseInt(x))) ), R.map(R.sortBy(([x]) => x)), R.countBy(([a, b]) => overlapsWith(a, b)) );