프로그래머스/Lv.1
프로그래머스 코딩테스트 연습 Lv.1 Swift
-
import Foundation func solution(_ n:Int64) -> Int64 { return Int64(String(String(n).sorted{ $0 > $1 }))! }
[Swift] 정수 내림차순으로 배치하기import Foundation func solution(_ n:Int64) -> Int64 { return Int64(String(String(n).sorted{ $0 > $1 }))! }
2023.02.16 -
import Foundation func solution(_ n:Int64) -> [Int] { return "\(n)".compactMap { $0.hexDigitValue }.reversed() }
[Swift] 자연수 뒤집어 배열로 만들기import Foundation func solution(_ n:Int64) -> [Int] { return "\(n)".compactMap { $0.hexDigitValue }.reversed() }
2023.02.15 -
import Foundation func solution(_ n:Int) -> Int { return "\(n)".compactMap { $0.hexDigitValue }.reduce(0, +) }
[Swift] 자릿수 더하기import Foundation func solution(_ n:Int) -> Int { return "\(n)".compactMap { $0.hexDigitValue }.reduce(0, +) }
2023.02.15 -
import Foundation func solution(_ s:String) -> String { return s.components(separatedBy: " ").map { $0.enumerated().map { $0.offset % 2 == 0 ? $0.element.uppercased() : $0.element.lowercased() } }.map { $0.joined() }.joined(separator: " ") }
[Swift] 이상한 문자 만들기import Foundation func solution(_ s:String) -> String { return s.components(separatedBy: " ").map { $0.enumerated().map { $0.offset % 2 == 0 ? $0.element.uppercased() : $0.element.lowercased() } }.map { $0.joined() }.joined(separator: " ") }
2023.02.15 -
import Foundation func solution(_ absolutes:[Int], _ signs:[Bool]) -> Int { return (0..
[Swift] 음양 더하기import Foundation func solution(_ absolutes:[Int], _ signs:[Bool]) -> Int { return (0..
2023.02.15 -
import Foundation func solution(_ babbling:[String]) -> Int { var count: Int = 0 for element in babbling { var str = String(element) str = str.replacingOccurrences(of: "aya", with: "1") str = str.replacingOccurrences(of: "ye", with: "2") str = str.replacingOccurrences(of: "woo", with: "3") str = str.replacingOccurrences(of: "ma", with: "4") if Int(str) != nil && !str.contains("11") && !str.conta..
[Swift] 옹알이 (2)import Foundation func solution(_ babbling:[String]) -> Int { var count: Int = 0 for element in babbling { var str = String(element) str = str.replacingOccurrences(of: "aya", with: "1") str = str.replacingOccurrences(of: "ye", with: "2") str = str.replacingOccurrences(of: "woo", with: "3") str = str.replacingOccurrences(of: "ma", with: "4") if Int(str) != nil && !str.contains("11") && !str.conta..
2023.02.15 -
import Foundation func solution(_ d:[Int], _ budget:Int) -> Int { var budget = budget return d.sorted().filter { budget -= $0 return budget >= 0 }.count }
[Swift] 예산import Foundation func solution(_ d:[Int], _ budget:Int) -> Int { var budget = budget return d.sorted().filter { budget -= $0 return budget >= 0 }.count }
2023.02.15 -
import Foundation func solution(_ numbers: [Int]) -> Int { return (0...9).filter { !numbers.contains($0) }.reduce(0, +) }
[Swift] 없는 숫자 더하기import Foundation func solution(_ numbers: [Int]) -> Int { return (0...9).filter { !numbers.contains($0) }.reduce(0, +) }
2023.02.15