meta: add lib and refactor
This commit is contained in:
parent
d5b828b1b9
commit
bfc3d61f5d
5 changed files with 19 additions and 29 deletions
|
@ -1,14 +1,7 @@
|
|||
with import <nixpkgs/lib>;
|
||||
with import ../lib;
|
||||
|
||||
let
|
||||
input = fileContents ./input.txt;
|
||||
|
||||
splitStr = pattern: flip pipe [
|
||||
(strings.split pattern)
|
||||
(filter isString)
|
||||
];
|
||||
|
||||
sum = foldl' add 0;
|
||||
in
|
||||
|
||||
pipe input [
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
with import <nixpkgs/lib>;
|
||||
with import ../lib;
|
||||
|
||||
let
|
||||
input = fileContents ./input.txt;
|
||||
|
||||
splitStr = pattern: flip pipe [
|
||||
(strings.split pattern)
|
||||
(filter isString)
|
||||
];
|
||||
in
|
||||
|
||||
pipe input [
|
||||
|
@ -14,7 +9,7 @@ pipe input [
|
|||
(map (flip pipe [
|
||||
(splitStr "\n")
|
||||
(map toInt)
|
||||
(foldl' add 0)
|
||||
sum
|
||||
]))
|
||||
(foldl' max 0)
|
||||
]
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
with import <nixpkgs/lib>;
|
||||
with import ../lib;
|
||||
|
||||
let
|
||||
input = fileContents ./input.txt;
|
||||
|
||||
splitStr = pattern: flip pipe [
|
||||
(strings.split pattern)
|
||||
(filter isString)
|
||||
];
|
||||
|
||||
score = myAction: opponentShape: {
|
||||
X.A = 0 + 3;
|
||||
X.B = 0 + 1;
|
||||
|
@ -28,5 +23,5 @@ pipe input [
|
|||
elemAt
|
||||
(get: score (get 1) (get 0))
|
||||
]))
|
||||
(foldl' add 0)
|
||||
sum
|
||||
]
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
with import <nixpkgs/lib>;
|
||||
with import ../lib;
|
||||
|
||||
let
|
||||
input = fileContents ./input.txt;
|
||||
|
||||
splitStr = pattern: flip pipe [
|
||||
(strings.split pattern)
|
||||
(filter isString)
|
||||
];
|
||||
|
||||
score = myShape: opponentShape: {
|
||||
X.A = 3 + 1;
|
||||
X.B = 0 + 1;
|
||||
|
@ -28,5 +23,5 @@ pipe input [
|
|||
elemAt
|
||||
(get: score (get 1) (get 0))
|
||||
]))
|
||||
(foldl' add 0)
|
||||
sum
|
||||
]
|
||||
|
|
12
lib/default.nix
Normal file
12
lib/default.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
let
|
||||
nixpkgsLib = import <nixpkgs/lib>;
|
||||
|
||||
aocLib = with nixpkgsLib; {
|
||||
splitStr = pattern: flip pipe [
|
||||
(strings.split pattern)
|
||||
(filter isString)
|
||||
];
|
||||
|
||||
sum = foldl' add 0;
|
||||
};
|
||||
in nixpkgsLib // aocLib
|
Reference in a new issue