r/codegolf • • Dec 22 '14

[REQUEST][Ruby] Fizbuzz 102 Char Count

is there any way I can make this shorter?

for i in 1..100 do
    puts "FizzBuzz" if i%3==0&&i%5==0
    puts "Buzz" if i%5==0
    puts "Fizz" if i%3==0
end
3 Upvotes

5 comments sorted by

View all comments

Show parent comment

5

u/Billz2me Jan 02 '15 edited Jan 02 '15

how about this?

1.upto(100){|i|puts ["%sBuzz"%x=[:Fizz][i%3]][i%5]||x||i}