import Foundation
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"))!
}
'Algorithm > programmers' 카테고리의 다른 글
프로그래머스 - 실패율 2019 KAKAO BILND RECRUITMENT (카카오) (0) | 2024.09.15 |
---|---|
프로그래머스 - 크레인 인형뽑기 게임 (2019 카카오 개발자 겨울 인턴 문제) (0) | 2024.09.15 |
프로그래머스 - 성격 유형 검사하기 (카카오 인턴쉽) (0) | 2024.09.11 |
프로그래머스 - 키패드 누르기 (2022 카카오 인턴) (2) | 2024.09.11 |
프로그래머스 - 두 개 뽑아서 더하기 (0) | 2024.09.11 |
import Foundation
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"))!
}
'Algorithm > programmers' 카테고리의 다른 글
프로그래머스 - 실패율 2019 KAKAO BILND RECRUITMENT (카카오) (0) | 2024.09.15 |
---|---|
프로그래머스 - 크레인 인형뽑기 게임 (2019 카카오 개발자 겨울 인턴 문제) (0) | 2024.09.15 |
프로그래머스 - 성격 유형 검사하기 (카카오 인턴쉽) (0) | 2024.09.11 |
프로그래머스 - 키패드 누르기 (2022 카카오 인턴) (2) | 2024.09.11 |
프로그래머스 - 두 개 뽑아서 더하기 (0) | 2024.09.11 |