프로그래머스/Lv.1
프로그래머스 코딩테스트 연습 Lv.1 Swift
-
import Foundation func solution(_ n:Int) -> String { return "\(String(repeating: "수박", count: n/2))\(n % 2 == 0 ? "" : "수")" }
[Swift] 수박수박수박수박수박수?import Foundation func solution(_ n:Int) -> String { return "\(String(repeating: "수박", count: n/2))\(n % 2 == 0 ? "" : "수")" }
2023.02.14 -
import Foundation func isPrime(_ n: Int) -> Bool { if (n Int { return (2...n).filter { isPrime($0) }.count }
[Swift] 소수 찾기import Foundation func isPrime(_ n: Int) -> Bool { if (n Int { return (2...n).filter { isPrime($0) }.count }
2023.02.14 -
import Foundation func isPrime(num :Int) -> Bool { if num Int { var result = 0 let num = nums.sorted() for i in stride(from: 0, through: num.count-3, by: 1){ for j in stride(from: i+1, through: num.count-2, by: 1){ for k in stride(from: j+1, through..
[Swift] 소수 만들기import Foundation func isPrime(num :Int) -> Bool { if num Int { var result = 0 let num = nums.sorted() for i in stride(from: 0, through: num.count-3, by: 1){ for j in stride(from: i+1, through: num.count-2, by: 1){ for k in stride(from: j+1, through..
2023.02.14 -
import Foundation func solution(_ survey:[String], _ choices:[Int]) -> String { let type = [["R", "T"], ["C", "F"], ["J", "M"], ["A", "N"]] let score = [3,2,1,0,1,2,3] var mbti: [String: Int] = ["R" : 0, "T" : 0, "C" : 0, "F" : 0, "J" : 0, "M" : 0, "A" : 0, "N" : 0] zip(survey, choices).forEach { let first = String($0.first!) let last = String($0.last!) if $1 < 4 { mbti[first]! += score[$1 - 1] ..
[Swift] 성격 유형 검사하기import Foundation func solution(_ survey:[String], _ choices:[Int]) -> String { let type = [["R", "T"], ["C", "F"], ["J", "M"], ["A", "N"]] let score = [3,2,1,0,1,2,3] var mbti: [String: Int] = ["R" : 0, "T" : 0, "C" : 0, "F" : 0, "J" : 0, "M" : 0, "A" : 0, "N" : 0] zip(survey, choices).forEach { let first = String($0.first!) let last = String($0.last!) if $1 < 4 { mbti[first]! += score[$1 - 1] ..
2023.02.14 -
import Foundation func solution(_ seoul:[String]) -> String { return "김서방은 \(seoul.firstIndex(of: "Kim")!)에 있다" }
[Swift] 서울에서 김서방 찾기import Foundation func solution(_ seoul:[String]) -> String { return "김서방은 \(seoul.firstIndex(of: "Kim")!)에 있다" }
2023.02.14 -
import Foundation func solution(_ number:[Int]) -> Int { var result = 0 for i in 0..
[Swift] 삼총사import Foundation func solution(_ number:[Int]) -> Int { var result = 0 for i in 0..
2023.02.14 -
import Foundation func solution(_ price:Int, _ money:Int, _ count:Int) -> Int{ return max((count + 1) * count / 2 * price - money , 0) }
[Swift] 부족한 금액 계산하기import Foundation func solution(_ price:Int, _ money:Int, _ count:Int) -> Int{ return max((count + 1) * count / 2 * price - money , 0) }
2023.02.14 -
func solution(_ s:String) -> Int { return Int(s)! }
[Swift] 문자열 정수로 바꾸기func solution(_ s:String) -> Int { return Int(s)! }
2023.02.14