Files
advent-of-code-2023/day02/Part1.hs
2023-12-02 12:45:15 +01:00

18 lines
557 B
Haskell

module Part1 where
import Commons
checkRoundsPossible :: [Round] -> Bool
checkRoundsPossible [] = True
checkRoundsPossible (round: t) = red round <= 12 && green round <= 13 && blue round <= 14 && (checkRoundsPossible t)
checkGamePossible :: Game -> Bool
checkGamePossible Game{rounds=rounds} = checkRoundsPossible rounds
getPossibleIds :: [Game] -> [Int]
getPossibleIds [] = []
getPossibleIds (game: t) = if (checkGamePossible game)
then (gid game: getPossibleIds t)
else do getPossibleIds t