Skip to content

Instantly share code, notes, and snippets.

@vicxruiz
Created May 15, 2019 15:40
Show Gist options
  • Save vicxruiz/9e5259679f3f315c4813c097614ff672 to your computer and use it in GitHub Desktop.
Save vicxruiz/9e5259679f3f315c4813c097614ff672 to your computer and use it in GitHub Desktop.
extension Int {
func expressNumber() -> [Int] {
var result: [Int] = []
let stringNum = String(self)
var count = stringNum.count - 1
for x in stringNum {
var element = String(x)
let str = String(repeating: "0", count: count)
element += str
result.append(Int(element) ?? 0)
count -= 1
}
return result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment