import Foundation
func solution(_ babbling:[String]) -> Int {
var count: Int = 0
for element in babbling {
var str = String(element)
str = str.replacingOccurrences(of: "aya", with: "1")
str = str.replacingOccurrences(of: "ye", with: "2")
str = str.replacingOccurrences(of: "woo", with: "3")
str = str.replacingOccurrences(of: "ma", with: "4")
if Int(str) != nil && !str.contains("11") && !str.contains("22") && !str.contains("33") && !str.contains("44"){
count += 1
}
}
return count
}
'프로그래머스 > Lv.1' 카테고리의 다른 글
[Swift] 이상한 문자 만들기 (0) | 2023.02.15 |
---|---|
[Swift] 음양 더하기 (0) | 2023.02.15 |
[Swift] 예산 (0) | 2023.02.15 |
[Swift] 없는 숫자 더하기 (0) | 2023.02.15 |
[Swift] 약수의 합 (0) | 2023.02.15 |