fork download
  1. #!/usr/bin/env ruby
  2.  
  3. def fizzbuzz a, b, n
  4. (1..n).map do |x|
  5. case
  6. when x % (a * b) == 0 then 'FB'
  7. when x % a == 0 then 'F'
  8. when x % b == 0 then 'B'
  9. else x
  10. end
  11. end
  12. end
  13.  
  14. if __FILE__ == $0
  15. File::open(ARGV.first) do |f|
  16. f.each do |l|
  17. puts fizzbuzz(*l.split.map { |x| x.to_i }).join ' '
  18. end
  19. end
  20. end
Runtime error #stdin #stdout 0s 4760KB
stdin
1
2
10
42
11
stdout
Standard output is empty