다트게임
-
[프로그래머스][Swift] 다트 게임알고리즘 2022. 7. 14. 14:33
func solution(_ dartResult:String) -> Int { let arr = dartResult.map { $0 } var arr2: [Int] = [] var result: Int = 0 for i in 0.. 1 { if arr[i - 2].isNumber == true { result += 10 } } result += Int(String(arr[i - 1]))! } else if arr[i] == "D" { if i > 1 { if arr[i - 2].isNumber == true { result += 10 * 10 } } result += Int(String(arr[i - 1]))! * Int(String(arr[i - 1]))! } else { if i > 1 { if ar..