Created
December 1, 2015 16:44
-
-
Save julsfelic/bd7b711d56a79e2b584e 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
# Clearest way possible | |
0.upto(1000) do |n| | |
if n.zero? | |
puts n | |
elsif (n % 3 == 0) && (n % 5 == 0) && (n % 7 == 0) | |
puts "SuperFizzBuzz" | |
elsif (n % 3 == 0) && (n % 7 == 0) | |
puts "SuperFizz" | |
elsif (n % 5 == 0) && (n % 7 == 0) | |
puts "SuperBuzz" | |
elsif (n % 3 == 0) | |
puts "Fizz" | |
elsif (n % 5 == 0) | |
puts "Buzz" | |
elsif (n % 7 == 0) | |
puts "Super" | |
else | |
puts n | |
end | |
end | |
# Fewest instructions / lines possible | |
0.upto(1000) do |n| | |
next puts n if n.zero? | |
next puts "SuperFizzBuzz" if n % 3 == 0 && n % 5 == 0 && n % 7 == 0 | |
next puts "SuperFizz" if n % 3 == 0 && n % 7 == 0 | |
next puts "SuperBuzz" if n % 5 == 0 && n % 7 == 0 | |
next puts "Fizz" if n % 3 == 0 | |
next puts "Buzz" if n % 5 == 0 | |
next puts "Super" if n % 7 == 0 | |
puts n | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment