diff --git a/1/solution.nix b/1/solution.nix index 7e3364d..5cca1a0 100644 --- a/1/solution.nix +++ b/1/solution.nix @@ -6,7 +6,7 @@ let totalsPerElf = map sum elfCalories; part1 = maxList totalsPerElf; - part2 = sum (topOfList 3 (sortList totalsPerElf)); + part2 = sum (take 3 (sortList totalsPerElf)); in { inherit part1; inherit part2; diff --git a/2/solution.nix b/2/solution.nix index 2acaf2b..b4e80dc 100644 --- a/2/solution.nix +++ b/2/solution.nix @@ -28,7 +28,7 @@ let if b == 0 then mkLoss a else if b == 1 then mkDraw a else mkWin a; - makeBestMoves = m: map (pair: split pair (a: b: [a (bestMove a b)] )) m; + makeBestMoves = map (pair: split pair (a: b: [a (bestMove a b)] )); in { part1 = totalScore matches; part2 = totalScore (makeBestMoves matches); diff --git a/util.nix b/util.nix index 0d67b5d..f8cd00c 100644 --- a/util.nix +++ b/util.nix @@ -13,8 +13,6 @@ let maxList = lib.foldr lib.max 0; # Sorts a int list. Greatest value first sortList = lib.sort (x: y: x > y); - # Returns the top cnt items of the list - 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