Created
October 31, 2012 09:15
-
-
Save Abizern/3986006 to your computer and use it in GitHub Desktop.
A better solution to the Google Code Jam problem "Reverse Words"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
{- | |
Problem statement: | |
http://code.google.com/codejam/contest/351101/dashboard#s=p1 | |
Run as a script with runghc, or compile with ghc --make -O2 | |
input and output is by redirection; | |
$ ./reverse_words < input_file > output_file | |
-} | |
import Control.Monad | |
main :: IO () | |
main = do | |
n <- readLn | |
forM_ [1..n] $ \i -> do | |
solution <- fmap (unwords . reverse . words) getLine | |
putStrLn $ "Case #" ++ show i ++ ": " ++ solution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment