Last active
September 22, 2023 08:32
-
-
Save otamajakusi/0d24513f7344fe2a4ceb943a78081f88 to your computer and use it in GitHub Desktop.
fizzbuzz ruby implementation inspired by https://gist.github.com/kazuho/3300555
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
fizz = _fizz = lambda do | |
fizz = lambda do | |
fizz = lambda do | |
fizz = _fizz | |
"Fizz" | |
end | |
"" | |
end | |
"" | |
end | |
buzz = _buzz = lambda do | |
buzz = lambda do | |
buzz = lambda do | |
buzz = lambda do | |
buzz = lambda do | |
buzz = _buzz | |
"Buzz" | |
end | |
"" | |
end | |
"" | |
end | |
"" | |
end | |
"" | |
end | |
n = 0 | |
fizzbuzz = lambda do | |
n += 1 | |
s = fizz.call() + buzz.call() | |
puts (s.empty? ? n.to_s : s) | |
end | |
(1..15).each do |n| | |
fizzbuzz.call() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment