Skip to content

Instantly share code, notes, and snippets.

@otamajakusi
Last active September 22, 2023 08:32
Show Gist options
  • Save otamajakusi/0d24513f7344fe2a4ceb943a78081f88 to your computer and use it in GitHub Desktop.
Save otamajakusi/0d24513f7344fe2a4ceb943a78081f88 to your computer and use it in GitHub Desktop.
fizzbuzz ruby implementation inspired by https://gist.github.com/kazuho/3300555
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