Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- # get count from file specified as input param
- cnt = File.open(ARGV[0]).readline.strip.to_i
- # iterate...
- # decided to minimize the number of mod operations by using a bit mask
- 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
Add Comment
Please, Sign In to add comment