Created
June 23, 2017 05:07
-
-
Save kenwilcox/9a11a225af059bcde0cf3629c793b411 to your computer and use it in GitHub Desktop.
FizzBuzz Count
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
var counter = [ | |
"fizz": 0, | |
"buzz": 0, | |
"fizzbuzz": 0, | |
"numbers": 0 | |
] | |
for i in 1...100 { | |
switch i { | |
case let x where (x % 3) == 0 && (x % 5) == 0: | |
counter["fizzbuzz"]? += 1 | |
print("FizzBuzz") | |
case let x where (x % 5) == 0: | |
counter["buzz"]? += 1 | |
print("Buzz") | |
case let x where (x % 3) == 0: | |
counter["fizz"]? += 1 | |
print("Fizz") | |
default: | |
counter["numbers"]? += 1 | |
print("\(i)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment