This commit is contained in:
Max Headroom 2022-12-02 15:38:51 +01:00
commit 56f51ca599
3 changed files with 2296 additions and 0 deletions

24
1/advanced.nix Normal file
View file

@ -0,0 +1,24 @@
with import <nixpkgs/lib>;
let
input = fileContents ./input.txt;
splitStr = pattern: flip pipe [
(strings.split pattern)
(filter isString)
];
sum = foldl' add 0;
in
pipe input [
(splitStr "\n\n")
(map (flip pipe [
(splitStr "\n")
(map toInt)
sum
]))
(sort (flip lessThan))
(take 3)
sum
]

20
1/basic.nix Normal file
View file

@ -0,0 +1,20 @@
with import <nixpkgs/lib>;
let
input = fileContents ./input.txt;
splitStr = pattern: flip pipe [
(strings.split pattern)
(filter isString)
];
in
pipe input [
(splitStr "\n\n")
(map (flip pipe [
(splitStr "\n")
(map toInt)
(foldl' add 0)
]))
(foldl' max 0)
]

2252
1/input.txt Normal file

File diff suppressed because it is too large Load diff