As part of my preparation for Google Code Jam
I’ve been working through the practice problems with Haskell.
I made a screencast on solving the
Reverse Words
problem, along with the mechanics of getting the problem inputs and submitting solutions. The style was heavily influenced by a sequence on
Data Driven Programming in Haskell by
Jonas Tullus
I moved at a slower pace, and talking and typing seem to have confused my brain
so I think I lapsed into gibberish in a couple of places. (If you know me,
you’ll know that’s nothing new).
moduleMainwhere{- - Problem Statement: - http://code.google.com/codejam/contest/351101/dashboard#s=p1 - - Usage either compile or use runhaskell / runghc - Pass the input file as the sole command line argument - Redirect output if you want the results to go in a file -}importIOimportSystem.EnvironmentimportData.ListreverseWords::String->StringreverseWords=unwords.reverse.wordsboilerPlate::[String]boilerPlate=["Case #"++shown++": "|n<-[1..]]standardOutput::[String]->[String]standardOutput=zipWith(++)boilerPlatemain=do(f:_)<-getArgsfile<-readFilefletcases=tail$linesfilesolutions=standardOutput$mapreverseWordscasesputStrLn$unlines$solutions