Last active
June 17, 2022 10:54
-
-
Save taea/44c5ca2d4df9431409ce8a57386c87c1 to your computer and use it in GitHub Desktop.
恥ずかしくて提出されなかった fizzbuzz 珍回答の供養
This file contains hidden or 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 eval_string(x, y) | |
(x / y.to_f).to_s.slice(/\..*/) == ".0" | |
end | |
(1..20).each do |x| | |
if eval_string(x, 5) && eval_string(x, 3) | |
puts "FizzBuzz" | |
elsif eval_string(x, 5) | |
puts "Buzz" | |
elsif eval_string(x, 3) | |
puts "Fizz" | |
else | |
puts x | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment