We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💬 문제
[프로그래머스](https://school.programmers.co.kr/learn/courses/30/lessons/17682/solution_groups?language=swift)
💬 Idea
💬 풀이
func solution(dartResult:String) -> Int { let dict = ["S": 1, "D": 2, "T": 3] let str: [String] = Array(dartResult).map({ String($0) }) var num: [Int] = [] var cutIndex = 0 for (index, i) in dartResult.enumerated() { if dartResult.filter({ !$0.isNumber }).contains(i) { let n = str[cutIndex..<index].joined() if n != "" { num.append(Int(n)!) } cutIndex = index + 1 if i == "S" || i == "D" || i == "T" { num[num.count - 1] = Int(pow(Double(num[num.count - 1]), Double(dict[String(i)]!))) } else if i == "*" { num[num.count - 1] *= 2 if num.count - 2 >= 0 { num[num.count - 2] *= 2 } } else { num[num.count - 1] *= -1 } } } return num.reduce(0, +) }
func solution(dartResult:String) -> Int { let dict = ["S": 1, "D": 2, "T": 3] let str: [String] = Array(dartResult).map({ String($0) }) var num: [Int] = [] var cutIndex = 0 for (index, i) in dartResult.enumerated() { switch i { case "S", "D", "T": num.append(Int(str[cutIndex..<index].joined()) ?? 0) num[num.count - 1] = Int(pow(Double(num[num.count - 1]), Double(dict[String(i)]!))) cutIndex = index + 1 case "*": num[num.count - 1] *= 2 if num.count - 2 >= 0 { num[num.count - 2] *= 2 } cutIndex = index + 1 case "#": num[num.count - 1] *= -1 cutIndex = index + 1 default: break } } return num.reduce(0, +) }
The text was updated successfully, but these errors were encountered:
#69 - 다트 게임 문제 풀이
0d404e1
25c9615
hwangJi-dev
No branches or pull requests
💬 문제
[프로그래머스](https://school.programmers.co.kr/learn/courses/30/lessons/17682/solution_groups?language=swift)
💬 Idea
→ 10을 문자열로 다루면 1, 0으로 잘리기 때문에 이렇게 잘라주는 것이다!
💬 풀이
The text was updated successfully, but these errors were encountered: