Skip to content

Instantly share code, notes, and snippets.

@kmdsbng
Created February 27, 2018 14:26
Show Gist options
  • Save kmdsbng/43ecad7f0a6ee917dad9204e65010383 to your computer and use it in GitHub Desktop.
Save kmdsbng/43ecad7f0a6ee917dad9204e65010383 to your computer and use it in GitHub Desktop.
# 応用問題
def main
values = (1..100).map {|i|
i_name = i.to_s
three = i_name =~ /3/ || i % 3 == 0
five = i_name =~ /5/ || i % 5 == 0
if three && five
'FizzBuzz'
elsif five
'Buzz'
elsif three
'Fizz'
else
i
end
}
puts values
end
case $PROGRAM_NAME
when __FILE__
main
when /spec[^\/]*$/
# {spec of the implementation}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment