Guest User

Untitled

a guest
Jul 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. # get count from file specified as input param
  4. cnt = File.open(ARGV[0]).readline.strip.to_i
  5.  
  6. # iterate...
  7. # decided to minimize the number of mod operations by using a bit mask
  8. 1.upto(cnt).each do |i|
  9. mask = i % 3 == 0 ? 1 : 0
  10. mask += i % 5 == 0 ? 2 : 0
  11. case mask
  12. when 1: puts "Hoppity"
  13. when 2: puts "Hophop"
  14. when 3: puts "Hop"
  15. end
  16. end
Add Comment
Please, Sign In to add comment