Created
May 15, 2019 15:40
-
-
Save vicxruiz/9e5259679f3f315c4813c097614ff672 to your computer and use it in GitHub Desktop.
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
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