This commit is contained in:
2023-12-02 12:45:15 +01:00
parent 787691d640
commit b167933285
4 changed files with 87 additions and 0 deletions

18
day02/Part2.hs Normal file
View File

@@ -0,0 +1,18 @@
module Part2 where
import Commons
getMinCubesRound :: [Round] -> Round
getMinCubesRound (round: []) = round
getMinCubesRound (round: otherRound: t) = getMinCubesRound (Round {red = max (red round) (red otherRound),
green = max (green round) (green otherRound),
blue = max (blue round) (blue otherRound)}: t)
getPowerGame :: Game -> Int
getPowerGame Game{rounds=rounds} = let minRound = getMinCubesRound rounds
in (red minRound) * (green minRound) * (blue minRound)
getPower :: [Game] -> [Int]
getPower [] = []
getPower (game: t) = (getPowerGame game: getPower t)