Created
January 9, 2019 16:58
-
-
Save Viniciuscarvalho/6581588e621ec5ccf97e3ecaaca0801d to your computer and use it in GitHub Desktop.
Code Kata - Kyu 7 - Don't give me five
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
| // In this kata you get the start number and the end number of a region and should return the count of all numbers except numbers with a 5 in it. The start and the end number are both inclusive! | |
| // Examples: | |
| // 1,9 -> 1,2,3,4,6,7,8,9 -> Result 8 | |
| // 4,17 -> 4,6,7,8,9,10,11,12,13,14,16,17 -> Result 12 | |
| // The result may contain fives. ;-) | |
| // The start number will always be smaller than the end number. Both numbers can be also negative! | |
| ------------------------------------------------------------------------- | |
| func dontGiveMeFive(_ start: Int, _ end: Int) -> Int { | |
| var numbersCount = 0 | |
| for number in start...end { | |
| if String(number).contains("5") != true { | |
| numbersCount += 1 | |
| } | |
| } | |
| return numbersCount | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment