12 lines
361 B
Nix
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);
|
|
}
|