programmers.co.kr/learn/courses/30/lessons/12901 나의 풀이 func solution(_ a:Int, _ b:Int) -> String { let week: [String] = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"] let month: [Int] = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] var day: Int = b for i in 0.. String { let w = ["THU", "FRI", "SAT", "SUN", "MON", "TUE", "WED"] let monthDay = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31..
programmers.co.kr/learn/courses/30/lessons/42748 나의 풀이 import Foundation func solution(_ array:[Int], _ commands:[[Int]]) -> [Int] { var result: [Int] = [] commands.forEach { test in let index = array.index(test[0]-1, offsetBy: test[1]-test[0]+1) let a = Array(array[test[0]-1.. [Int] { return commands.map({(key) in return array[(key[0]-1)...(key[1]-1)].sorted()[key[2]-1] }) } 배울 점 1. 따로 마지막 inde..
programmers.co.kr/learn/courses/30/lessons/68935 나의 풀이 import Foundation func solution(_ n:Int) -> Int { var newN: String = String(n, radix: 3) newN = String(newN.reversed()[0.. Int { var num = n var nArray: [Int] = [] while num > 0 { nArray.append(num % 3) num /= 3 } var power: Int = 1 var ans: Int = 0 for n in nArray.reversed() { ans += n * power power *= 3 } return ans } 다른 사람의 풀이 import Foun..