Created
November 12, 2009 21:39
-
-
Save jeffreyiacono/233303 to your computer and use it in GitHub Desktop.
fb careers challenge puzzle: hoppity
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
#!/usr/bin/ruby | |
# get file name arg from command line | |
File.open(ARGV[0], 'r') do | f | | |
# read the first line containing the integer | |
(1..f.readline.strip.to_i).each do | i | | |
# div by 3? | |
if ( i % 3 ) == 0 then | |
# and by 5? | |
if ( i % 5 ) == 0 then | |
puts 'Hop' | |
else | |
puts 'Hoppity' | |
end | |
# or by 5? | |
elsif ( i % 5 ) == 0 then | |
puts 'Hophop' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment