-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
https://school.programmers.co.kr/learn/courses/30/lessons/81301
"one4seveneight" > 1478
"23four5six7" > 234567
"2three45sixseven" > 234567
"123" > 123
import Foundation
func solution(_ s:String) -> Int {
let tuple = ["zero": "0", "one": "1", "two": "2", "three": "3", "four": "4", "five": "5", "six": "6", "seven": "7", "eight": "8", "nine": "9"]
var result = ""
var temp = ""
for i in s {
if let num = Int(String(i)) {
result += String(num)
} else {
temp += String(i)
if let str = tuple[temp] {
result += str
temp = ""
}
}
}
return Int(String(result))!;
}