Last active
July 17, 2020 15:55
-
-
Save marlonjames71/f0f86e3d5f15a36d0bf6095e78e485ab to your computer and use it in GitHub Desktop.
This function takes an int and returns an array of numbers which is the original number broken down into it's smaller parts
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
func expand(number: Int) -> [Int] { | |
var expandedNums: [Int] = [] | |
var i = 10 | |
while (number > i / 10) { | |
expandedNums.append(number % i - number % (i / 10)) | |
i *= 10 | |
} | |
return expandedNums | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment