Skip to content

Instantly share code, notes, and snippets.

@digitalex
Created December 15, 2010 11:41
Show Gist options
  • Save digitalex/741880 to your computer and use it in GitHub Desktop.
Save digitalex/741880 to your computer and use it in GitHub Desktop.
Solution to facebook puzzle 'Hoppity', in Haskell
-- Facebook puzzle #1 - Hors d'oeuvres
-- http://www.facebook.com/careers/puzzles.php?puzzle_id=7
output 0 = return ()
output x =
putStrLn (gethop x)
output (x - 1)
gethop x
| div3 x && div5 x = "Hop\n"
| div3 x = "Hoppity\n"
| div5 x = "Hophop\n"
| otherwise = ""
divides y x = x `mod` y == 0
div3 = divides 3
div5 = divides 5
main = do
instr <- getLine
output (read instr::Int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment