From 2cf462ad9d69f95ac2ee00da77b13f1eae4ebb0b Mon Sep 17 00:00:00 2001 From: George Thomas Date: Fri, 19 Dec 2025 16:22:26 +0000 Subject: [PATCH] Refactor `findMax` to more closely match Rust --- haskell/Puzzles/Day3.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haskell/Puzzles/Day3.hs b/haskell/Puzzles/Day3.hs index 2167af3..cf80c5b 100644 --- a/haskell/Puzzles/Day3.hs +++ b/haskell/Puzzles/Day3.hs @@ -37,4 +37,4 @@ maxBatteries n0 (Bank bs0) = flip unfoldrM (n0, toList bs0) \case -- returns the leftmost element in case of a tie findMax :: (Ord a) => NonEmpty a -> (Int, a) -findMax = foldl1' (\m x -> if snd x > snd m then x else m) . NE.zip (0 :| [1 ..]) +findMax = maximumBy (comparing snd) . NE.reverse . NE.zip (0 :| [1 ..])