Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
![](/static/devrant/img/pipeless-devrant-banner-white.png)
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
LLAMS37516yIf you havent seen it already. You should search Github for FizzBuzz Enterprise. Its hilarious.
-
-vim-31696yfizzbuzz = lambda num_range: print('\n'.join(str(x) if x%5 and x%3 else (('fizz' if not x%3 else '') + ('buzz' if not x%5 else '')) for x in range(1, num_range+1)))
-
Root823426ydef fizzbuzz(limit)
1.upto(limit+1) do |num|
printf "fizz" if num%3==0
printf "buzz" if num%5==0
printf "\n"
end
end
fizzbuzz(92)
7+1 lines, so it's a little long, but very easy to read. Would be slightly faster (and more easily extensible) if I used string concatenation and a single printf, but that would add another line. -
Root823426ydef fizzbuzz(limit)
(1..limit+1).to_a.collect{|num|{1:"", 3:"fizz", 5:"buzz"}.map{|k,v| v if num%k.to_i==0}.join+"\n"}
end
printf fizzbuzz(92)
More extensible golfy one-liner 😊
Related Rants
-
Aitkotw2
That first HTML page that I wrote and saw changes in the browser accordingly.
-
BlueNutterfly11The times when we coded in C# on weekends at the university and it was a 4-hour nonstop process. I LOVED it. T...
-
nitwhiz4I once wrote about 100 lines of C code without compiling or testing in between in notepad++. And it had no er...
Writing FizzBuzz in 3 lines via python list comprehentions.
rant
wk95