분류 전체보기
-
import Foundation func solution(_ numbers:[Int], _ k:Int) -> Int { (k - 1) * 2 % numbers.count + 1 }
[Swift] 공던지기import Foundation func solution(_ numbers:[Int], _ k:Int) -> Int { (k - 1) * 2 % numbers.count + 1 }
2022.12.13 -
import Foundation func solution(_ lines:[[Int]]) -> Int { var wholeLine = Array(repeating: 0, count: 200) for line in lines { for idx in stride(from: line.first!, to: line.last!, by: 1) { wholeLine[idx] += 1 } } return wholeLine.filter { $0 >= 2 }.count }
[Swift] 겹치는 선분의 길이import Foundation func solution(_ lines:[[Int]]) -> Int { var wholeLine = Array(repeating: 0, count: 200) for line in lines { for idx in stride(from: line.first!, to: line.last!, by: 1) { wholeLine[idx] += 1 } } return wholeLine.filter { $0 >= 2 }.count }
2022.12.13 -
import Foundation func solution(_ hp:Int) -> Int { return (hp / 5) + ((hp % 5) / 3) + (hp % 3) }
[Swift] 개미 군단import Foundation func solution(_ hp:Int) -> Int { return (hp / 5) + ((hp % 5) / 3) + (hp % 3) }
2022.12.13 -
import Foundation func solution(_ angle:Int) -> Int { if angle == 180 { return 4 } else if angle > 90 { return 3 } else if angle == 90 { return 2 } else { return 1 } return 0 }
[Swift] 각도기import Foundation func solution(_ angle:Int) -> Int { if angle == 180 { return 4 } else if angle > 90 { return 3 } else if angle == 90 { return 2 } else { return 1 } return 0 }
2022.12.13 -
import Foundation func solution(_ array:[Int]) -> [Int] { [array.max()!, array.index(of: array.max()!)!] }
[Swift] 가장 큰 수 찾기import Foundation func solution(_ array:[Int]) -> [Int] { [array.max()!, array.index(of: array.max()!)!] }
2022.12.13 -
import Foundation func solution(_ rsp:String) -> String { rsp.map { $0 == "0" ? "5" : $0 == "2" ? "0" : "2" }.joined() }
[Swift] 가위 바위 보import Foundation func solution(_ rsp:String) -> String { rsp.map { $0 == "0" ? "5" : $0 == "2" ? "0" : "2" }.joined() }
2022.12.13 -
import Foundation func solution(_ array:[Int], _ n:Int) -> Int { array.sorted { abs($0 - n) < abs($1 - n) }.first! }
[Swift] 가까운 수import Foundation func solution(_ array:[Int], _ n:Int) -> Int { array.sorted { abs($0 - n) < abs($1 - n) }.first! }
2022.12.13 -
import Foundation func solution(_ order:Int) -> Int { String(order).filter {$0 == "3" || $0 == "6" || $0 == "9"}.count }
[Swift] 369게임import Foundation func solution(_ order:Int) -> Int { String(order).filter {$0 == "3" || $0 == "6" || $0 == "9"}.count }
2022.12.13