13 lines
362 B
Nix
13 lines
362 B
Nix
|
{ lib, utils, ... }:
|
||
|
with lib;
|
||
|
with builtins;
|
||
|
with utils;
|
||
|
let
|
||
|
numbers = map (l: map toInt (splitWhitespace l)) (readLines ./input);
|
||
|
left = sortOn noop (map (flip elemAt 0) numbers);
|
||
|
right = sortOn noop (map (flip elemAt 1) numbers);
|
||
|
in {
|
||
|
part1 = listSum (zipListsWith delta left right);
|
||
|
part2 = listSum (map (x: x * (count (y: x == y) right)) left);
|
||
|
}
|