day 1
This commit is contained in:
commit
56f51ca599
3 changed files with 2296 additions and 0 deletions
24
1/advanced.nix
Normal file
24
1/advanced.nix
Normal 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
20
1/basic.nix
Normal 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
2252
1/input.txt
Normal file
File diff suppressed because it is too large
Load diff
Reference in a new issue