13 lines
365 B
JavaScript
13 lines
365 B
JavaScript
import * as R from "remeda";
|
|
|
|
export const solutionPart2 = R.createPipe(
|
|
(text) => text.split("\n"),
|
|
R.filter(R.identity),
|
|
R.map((line) => line.split("")),
|
|
R.chunk(3),
|
|
R.map((group) => group.reduce((a, b) => R.intersection(a, b))),
|
|
R.map((line) => line[0].charCodeAt(0)),
|
|
R.map((code) => (code > 96 ? code - 96 : code - 38)),
|
|
R.sumBy(R.identity)
|
|
);
|