data Rock data Paper data Scissors type X = Rock type Y = Paper type Z = Scissors type A = Rock type B = Paper type C = Scissors data Action = X | Y | Z deriving (Show,Read, Eq) data Enemy = A | B | C deriving (Show,Read, Eq) data Game = Game Enemy Action deriving (Show,Read) selectedScore :: Action -> Int selectedScore X = 1 selectedScore Y = 2 selectedScore Z = 3 resultScore :: Game -> Int resultScore (Game A X) = 3 resultScore (Game A Y) = 6 resultScore (Game A Z) = 0 resultScore (Game B X) = 0 resultScore (Game B Y) = 3 resultScore (Game B Z) = 6 resultScore (Game C X) = 6 resultScore (Game C Y) = 0 resultScore (Game C Z) = 3 gameScore :: Game -> Int gameScore (Game enemy action) = (resultScore (Game enemy action)) + selectedScore action main = do input <- readFile "input.txt" putStrLn $ show$ sum $ map (gameScore . read . ("Game "<> )) $ lines input