Skip to content

Instantly share code, notes, and snippets.

@paulclip
Created December 30, 2010 13:20
Show Gist options
  • Save paulclip/759787 to your computer and use it in GitHub Desktop.
Save paulclip/759787 to your computer and use it in GitHub Desktop.
Hoppity Optimized
#!/usr/bin/ruby
# get count from file specified as input param
cnt = File.open(ARGV[0]).readline.strip.to_i
while cnt <= 15 do
puts "Hoppity\nHophop\nHoppity\nHoppity\nHophop\nHoppity\nHop\n"
cnt -= 15
end
1.upto(cnt).each do |i|
mask = i % 3 == 0 ? 1 : 0
mask += i % 5 == 0 ? 2 : 0
case mask
when 1: puts "Hoppity"
when 2: puts "Hophop"
when 3: puts "Hop"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment