[프로그래머스] 숫자 문자열과 영단어 Swift

AekT·2021년 11월 12일
0

프로그래머스

목록 보기
5/6
post-thumbnail

프로그래머스 - 숫자 문자열과 영단어

문제 : https://programmers.co.kr/learn/courses/30/lessons/81301

Code :

func solution(_ s:String) -> Int {
    return Int(s.replacingOccurrences(of:"zero", with:"0")
               .replacingOccurrences(of: "one", with: "1")
               .replacingOccurrences(of: "two", with: "2")
               .replacingOccurrences(of: "three", with: "3")
               .replacingOccurrences(of: "four", with:"4")
               .replacingOccurrences(of: "five", with: "5")
               .replacingOccurrences(of: "six", with: "6")
               .replacingOccurrences(of: "seven", with: "7")
               .replacingOccurrences(of: "eight", with: "8")
               .replacingOccurrences(of: "nine", with: "9"))!
}
profile
으악

0개의 댓글