Created
December 15, 2010 11:41
-
-
Save digitalex/741880 to your computer and use it in GitHub Desktop.
Solution to facebook puzzle 'Hoppity', in Haskell
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
-- 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