the number is a multiple of 3 print “Fizz” • If the number is a multiple of 5 print “Buzz” • If the number is a multiple of 3 and 5 print “FizzBuzz” • Otherwise, Print the number.
If the string contains the word “Three” print “Fizz” • If the string contains the word “Five” print “Buzz” • If the string contains the words “Three” and “Five” print “FizzBuzz”
stringInput { var result = "" ! if string.rangeOfString("three", options: .CaseInsensitiveSearch) { result += "Fizz" } ! if string.rangeOfString("five", options: .CaseInsensitiveSearch) { result += "Buzz" } ! if result.isEmpty { result = string } ! println(result) }
(5, "Buzz")] let strOptions = [("three", "Fizz"), ("five", "Buzz")] var output = "" ! if let num = x as? Int { output = num.fizzBuzz(intOptions) } else if let str = x as? String { output = str.fizzBuzz(strOptions) } ! println(output) }