From 1a65daf518ccfec1188db5a99d720bb72f04c97b Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 3 Dec 2022 11:41:37 +0100 Subject: [PATCH] day 3 --- 3/advanced.nix | 23 ++++ 3/basic.nix | 30 +++++ 3/input.txt | 300 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/default.nix | 8 +- 4 files changed, 360 insertions(+), 1 deletion(-) create mode 100644 3/advanced.nix create mode 100644 3/basic.nix create mode 100644 3/input.txt diff --git a/3/advanced.nix b/3/advanced.nix new file mode 100644 index 0000000..85b498a --- /dev/null +++ b/3/advanced.nix @@ -0,0 +1,23 @@ +with import ../lib; + +let + input = fileContents ./input.txt; + + lowercasePrio = flip pipe [ strings.charToInt (flip sub 96) ]; + + prio = c: let + p = lowercasePrio c; + in if p > 0 then p else p + 58; +in + +pipe input [ + (splitStr "\n") + (groupwise 3) + (map (flip pipe [ + (map strings.stringToCharacters) + (l: foldl' intersectLists (head l) l) + head + prio + ])) + sum +] diff --git a/3/basic.nix b/3/basic.nix new file mode 100644 index 0000000..f05bbd1 --- /dev/null +++ b/3/basic.nix @@ -0,0 +1,30 @@ +with import ../lib; + +let + input = fileContents ./input.txt; + + chopInHalf = s: let + len = stringLength s; + in { + a = substring 0 (len / 2) s; + b = substring (len / 2) len s; + }; + + lowercasePrio = flip pipe [ strings.charToInt (flip sub 96) ]; + + prio = c: let + p = lowercasePrio c; + in if p > 0 then p else p + 58; +in + +pipe input [ + (splitStr "\n") + (map (flip pipe [ + chopInHalf + (mapAttrs (const strings.stringToCharacters)) + (unpackAttrsCall intersectLists) + head + prio + ])) + sum +] diff --git a/3/input.txt b/3/input.txt new file mode 100644 index 0000000..37c2369 --- /dev/null +++ b/3/input.txt @@ -0,0 +1,300 @@ +BccTFfTPTsffdDDqsq +lGGLQwFhDgWdqvhW +wbLNjGjlwLFrpSbllrHnHHRmmJVBmZJRRVcBTc +vvGLllBBLtllJnJFMZNjFcNG +bdhrhTgmhRrpLJMMNJgNffnf +qhRmT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VGbbVS +QCdnBFBndBQDnrqrnqqNhpNNLpHthsThjGCTLL +phCgcdrFbPLpgrbFHqQqzzlbGWGqQbHW +SFTvTnVVMRnNTNfSHjHQMDlHwDWlQwDz +TZmTvsFNmvTtsggpdJLBBsCs +PBBWQjvsPsHVsNMcSzNDjcGggS +ZtrTfTrrrrdCqpdtLNnMLLqNcgMzgHLq +CZFmdTrJtbZrBvWHVVvHbPQW +djcrrBljMrTdCTcdCClClMlqRvtNqqSRwFbNbwvNBNpSzq +QhPmGJnPVGVHHNzSqpzFwztF +nhgPFmsnLPGLhPDJhGTcDjMfrMMjMZWfjfWj diff --git a/lib/default.nix b/lib/default.nix index 09636b9..6fe3cb6 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,12 +1,18 @@ let nixpkgsLib = import ; - aocLib = with nixpkgsLib; { + aocLib = with nixpkgsLib; rec { + groupwise = size: l: let + rest = drop size l; + in [ (take size l) ] ++ optionals (rest != []) (groupwise size rest); + splitStr = pattern: flip pipe [ (strings.split pattern) (filter isString) ]; sum = foldl' add 0; + + unpackAttrsCall = f: attrs: f attrs.a attrs.b; }; in nixpkgsLib // aocLib