Skip to content

Instantly share code, notes, and snippets.

@marlonjames71
Last active July 17, 2020 15:55
Show Gist options
  • Save marlonjames71/f0f86e3d5f15a36d0bf6095e78e485ab to your computer and use it in GitHub Desktop.
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
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