programmers.co.kr/learn/courses/30/lessons/12910?language=swift 나의 풀이 func solution(_ arr:[Int], _ divisor:Int) -> [Int] { let result = arr.filter { $0%divisor == 0 } if result.count > 0 { return result.sorted() } else { return [-1] } } 다른 사람의 풀이 func solution(_ arr:[Int], _ divisor:Int) -> [Int] { let result = arr.filter{ $0 % divisor == 0}.sorted() return result.count == 0 ? [-1] : result }
나의 풀이 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..