Skip to content

Instantly share code, notes, and snippets.

@taea
Last active June 17, 2022 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taea/44c5ca2d4df9431409ce8a57386c87c1 to your computer and use it in GitHub Desktop.
Save taea/44c5ca2d4df9431409ce8a57386c87c1 to your computer and use it in GitHub Desktop.
恥ずかしくて提出されなかった fizzbuzz 珍回答の供養
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