This commit is contained in:
2023-12-07 15:16:58 +01:00
parent 05de161249
commit 1326fe7e33
5 changed files with 122 additions and 0 deletions

15
day07/Part1.hs Normal file
View File

@@ -0,0 +1,15 @@
module Part1 where
import Commons
import Data.List (sort, sortOn)
getHandValue :: Hand -> HandValue
getHandValue hand = HandValue {hand = hand, value = 100 ^ 5 * (getHandValueTypeFromSorted . sort) (values hand)
+ getHandSecondValue (values hand)}
sortHands :: [Hand] -> [Hand]
sortHands = map hand . sortHandValues . map getHandValue
getTotalWinnings :: [Hand] -> Int
getTotalWinnings = getWinningsFromSorted 1 . sortHands