Advent-of-Nix-2024/day1/default.nix
2024-12-01 15:59:47 +01:00

12 lines
361 B
Nix

{ lib, utils, ... }:
with lib;
with builtins;
with utils;
let
numbers = map (l: map toInt (splitWhitespace l)) (readLines ./input);
left = sort lessThan (map (flip elemAt 0) numbers);
right = sort lessThan (map (flip elemAt 1) numbers);
in {
part1 = listSum (zipListsWith delta left right);
part2 = listSum (map (x: x * (count (eq x) right)) left);
}