From fb7913ad3d0c7d25591e4331ad34afc4d3181073 Mon Sep 17 00:00:00 2001 From: zuckerberg <5-zuckerberg@users.noreply.git.neet.dev> Date: Sat, 3 Dec 2022 19:53:50 -0700 Subject: [PATCH] Cleanup functions --- 1/solution.nix | 2 +- util.nix | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/1/solution.nix b/1/solution.nix index a1084f7..7e3364d 100644 --- a/1/solution.nix +++ b/1/solution.nix @@ -6,7 +6,7 @@ let totalsPerElf = map sum elfCalories; part1 = maxList totalsPerElf; - part2 = sum (topOfList (sortList totalsPerElf) 3); + part2 = sum (topOfList 3 (sortList totalsPerElf)); in { inherit part1; inherit part2; diff --git a/util.nix b/util.nix index cfa07ad..0d67b5d 100644 --- a/util.nix +++ b/util.nix @@ -6,15 +6,15 @@ let # Passthrough trace for debugging pTrace = v: lib.traceSeq v v; # find the total sum of a int list - sum = l: lib.foldr (x: y: x + y) 0 l; + sum = lib.foldr (x: y: x + y) 0; # splits a list of length two into two params then they're passed to a func split = pair: f: f (lib.head pair) (lib.last pair); # Finds the max value in a list - maxList = l: lib.foldr lib.max 0 l; + maxList = lib.foldr lib.max 0; # Sorts a int list. Greatest value first - sortList = l: lib.sort (x: y: x > y) l; + sortList = lib.sort (x: y: x > y); # Returns the top cnt items of the list - topOfList = l: cnt: lib.take cnt l; + topOfList = cnt: lib.take cnt; # Cuts a list in half and returns the two parts in a list cutInHalf = l: [(lib.take (lib.length l / 2) l) (lib.drop (lib.length l / 2) l)]; # Splits a list into a list of lists with length cnt