adventofcode/2023/01/part1.js

17 lines
321 B
JavaScript

import * as R from 'remeda';
export const extract_number = (line) => {
const n = line.match(/(\d)/g);
return parseInt(
n[0] + n[n.length-1]
);
}
export const solution_1 = R.createPipe(
i => i.split("\n"),
R.compact,
R.map(extract_number),
R.sumBy(R.identity)
);