Created
February 27, 2018 14:26
-
-
Save kmdsbng/43ecad7f0a6ee917dad9204e65010383 to your computer and use it in GitHub Desktop.
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
# 応用問題 | |
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