2022-12-03 19:52:19 +00:00
|
|
|
import * as R from "remeda";
|
|
|
|
|
2022-12-03 20:26:15 +00:00
|
|
|
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)
|
|
|
|
);
|