Last active
August 29, 2015 14:26
-
-
Save stevenproctor/ecfb90fd6ceaa9880625 to your computer and use it in GitHub Desktop.
Translation of http://comp-phil.blogspot.com/2015/08/bro-do-you-even-fizzbuzz.html into Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_fizzbuzz(n) | |
fizz = ['', '', 'fizz'].cycle.lazy | |
buzz = ['', '', '', '', 'buzz'].cycle.lazy | |
fizzbuzz = fizz.zip buzz | |
puts (1..n). | |
zip(fizzbuzz.map(&:join)). | |
map {|number, translation| if translation.empty? then number else translation end}. | |
join("\n") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment