Skip to content

Instantly share code, notes, and snippets.

@jeffreyiacono
Created November 12, 2009 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreyiacono/233303 to your computer and use it in GitHub Desktop.
Save jeffreyiacono/233303 to your computer and use it in GitHub Desktop.
fb careers challenge puzzle: hoppity
#!/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