Created
December 30, 2010 13:20
-
-
Save paulclip/759787 to your computer and use it in GitHub Desktop.
Hoppity Optimized
This file contains hidden or 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 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