나의 풀이 import Foundation func solution(_ dartResult:String) -> Int { var point = [0, 0, 0] var square = [1, 1, 1] var opt = [1, 1, 1] var temp: Character = " " var index: Int = 0 var result: Int = 0 for c in dartResult { switch c{ case "0"..."9": if temp == "1", c == "0" { point[index-1] = 10 } else { point[index] = Int(String(c)) ?? 0 index += 1 } case "D": square[index-1] = 2 case "T": square[i..
programmers.co.kr/learn/courses/30/lessons/42889?language=swift 나의 풀이 import Foundation func solution(_ N:Int, _ stages:[Int]) -> [Int] { var failure: [Int: Float] = [:] var player: Int = stages.count for i in 1...N { let n = stages.filter { $0 == i }.count failure[i] = Float(n)/Float(player) player -= n } return failure.sorted(by: $1.value }).map {$0.key} }
programmers.co.kr/learn/courses/30/lessons/17681?language=swift 나의 풀이 import Foundation func solution(_ n:Int, _ arr1:[Int], _ arr2:[Int]) -> [String] { var answer: [String] = [] var newArr1 = arr1.map { String($0, radix: 2) } var newArr2 = arr2.map { String($0, radix: 2) } for i in 0..
programmers.co.kr/learn/courses/30/lessons/67256?language=swift 나의 풀이 import Foundation func solution(_ numbers:[Int], _ hand:String) -> String { var hands: [String] = [] var changedNum: [Int] = numbers // 처음 손의 좌표 var leftRight: [[Int]] = [[3,0], [3,2]] for i in 0.. distance(a: leftRight[1], b: point) { hands.append("R") leftRight[1] = point } else if distance(a: leftRight[0], b: point) < dista..