refactor day 3
This commit is contained in:
parent
89def61212
commit
f76dad98cf
2 changed files with 6 additions and 8 deletions
12
3/basic.nix
12
3/basic.nix
|
@ -5,10 +5,10 @@ let
|
||||||
|
|
||||||
chopInHalf = s: let
|
chopInHalf = s: let
|
||||||
len = stringLength s;
|
len = stringLength s;
|
||||||
in {
|
in [
|
||||||
a = substring 0 (len / 2) s;
|
(substring 0 (len / 2) s)
|
||||||
b = substring (len / 2) len s;
|
(substring (len / 2) len s)
|
||||||
};
|
];
|
||||||
|
|
||||||
lowercasePrio = flip pipe [ strings.charToInt (flip sub 96) ];
|
lowercasePrio = flip pipe [ strings.charToInt (flip sub 96) ];
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ pipe input [
|
||||||
(splitStr "\n")
|
(splitStr "\n")
|
||||||
(map (flip pipe [
|
(map (flip pipe [
|
||||||
chopInHalf
|
chopInHalf
|
||||||
(mapAttrs (const strings.stringToCharacters))
|
(map strings.stringToCharacters)
|
||||||
(unpackAttrsCall intersectLists)
|
(uncurry intersectLists)
|
||||||
head
|
head
|
||||||
prio
|
prio
|
||||||
]))
|
]))
|
||||||
|
|
|
@ -19,7 +19,5 @@ let
|
||||||
elemAt
|
elemAt
|
||||||
(get: f (get 0) (get 1))
|
(get: f (get 0) (get 1))
|
||||||
];
|
];
|
||||||
|
|
||||||
unpackAttrsCall = f: attrs: f attrs.a attrs.b;
|
|
||||||
};
|
};
|
||||||
in nixpkgsLib.fix aocLib
|
in nixpkgsLib.fix aocLib
|
||||||
|
|
Reference in a new issue