Skip to content

Instantly share code, notes, and snippets.

@jkramer
Created January 11, 2016 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkramer/08a7d19b6541a964a644 to your computer and use it in GitHub Desktop.
Save jkramer/08a7d19b6541a964a644 to your computer and use it in GitHub Desktop.
CodinGame - Chasm
import System.IO
import Control.Monad
main = do
hSetBuffering stdout NoBuffering -- DO NOT REMOVE
[road, gap, platform] <- replicateM 3 (fmap read getLine)
forever $ do
[speed, x] <- replicateM 2 (fmap read getLine)
putStrLn (command road gap platform speed x)
command road gap platform speed x
| x < road && speed < (gap + 1) = "SPEED"
| x < road && speed > (gap + 1) = "SLOW"
| x >= road = "SLOW"
| x + speed >= road = "JUMP"
| otherwise = "WAIT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment