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
|
||||
len = stringLength s;
|
||||
in {
|
||||
a = substring 0 (len / 2) s;
|
||||
b = substring (len / 2) len s;
|
||||
};
|
||||
in [
|
||||
(substring 0 (len / 2) s)
|
||||
(substring (len / 2) len s)
|
||||
];
|
||||
|
||||
lowercasePrio = flip pipe [ strings.charToInt (flip sub 96) ];
|
||||
|
||||
|
@ -21,8 +21,8 @@ pipe input [
|
|||
(splitStr "\n")
|
||||
(map (flip pipe [
|
||||
chopInHalf
|
||||
(mapAttrs (const strings.stringToCharacters))
|
||||
(unpackAttrsCall intersectLists)
|
||||
(map strings.stringToCharacters)
|
||||
(uncurry intersectLists)
|
||||
head
|
||||
prio
|
||||
]))
|
||||
|
|
|
@ -19,7 +19,5 @@ let
|
|||
elemAt
|
||||
(get: f (get 0) (get 1))
|
||||
];
|
||||
|
||||
unpackAttrsCall = f: attrs: f attrs.a attrs.b;
|
||||
};
|
||||
in nixpkgsLib.fix aocLib
|
||||
|
|
Reference in a new issue