Solve 2026-01

This commit is contained in:
2026-12-02 16:20:32 +01:00
parent 106c16ee1e
commit 82adaf36ac
5 changed files with 73 additions and 1 deletions
+21
View File
@@ -0,0 +1,21 @@
import { groupBy, multBy } from '../../utils/array.ts';
export function solveFirst(input: string): number {
const numbers = groupBy(input.split('\n').map(Number), (n) => n).toSorted(
(a, b) => b.elements.length - a.elements.length
);
const top3 = numbers.slice(0, 3);
return multBy(top3, (e) => e.key);
}
export function solveSecond(input: string): number {
const numbers = groupBy(input.split('\n').map(Number), (n) => n).toSorted(
(a, b) => a.elements.length - b.elements.length
);
const top3 = numbers.slice(0, 3);
return multBy(top3, (e) => e.key);
}