Skip to content

Instantly share code, notes, and snippets.

@sleepynate
Last active December 14, 2015 19:58
Show Gist options
  • Save sleepynate/5140058 to your computer and use it in GitHub Desktop.
Save sleepynate/5140058 to your computer and use it in GitHub Desktop.
import Control.Monad
data Gesture = Rock | Paper | Scissors deriving (Eq, Show, Read)
instance Ord Gesture where
a `compare` b
| a == b = EQ
Rock `compare` Scissors = GT
Paper `compare` Rock = GT
Scissors `compare` Paper = GT
_ `compare` _ = LT
readGes :: String -> Gesture
readGes = read
main = do
putStrLn "ROCK PAPER SCISSORS EPIC BATTLE TIEMS"
putStrLn "-------------------------------------"
putStrLn ""
putStrLn "INDICATE NUMBER OF DESTROYERS OF EACH OTHER"
x <- getLine
let players = read x::Int
moves <- replicateM players (putStrLn "What is your move!?!?!" >> getLine)
putStrLn $ show (maximum $ map readGes moves) ++ " wins"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment