전체 글 (184) 썸네일형 리스트형 [Day18-3] 간단한 식 계산하기 문제 내 정답 코드import Foundationfunc solution(_ binomial:String) -> Int { let component = binomial.components(separatedBy: " ") let (a, op, b) = (Int(component[0]), component[1], Int(component[2])) switch op { case "+": return a!+b! case "-": return a!-b! case "*": return a!*b! default: return 0 }} #1. 공백으로 문자열을 분리해주면 a, op, b를 얻을 수 있다.2. switch.. [Day18-2] 문자열 잘라서 정렬하기 문제 내 정답 코드import Foundationfunc solution(_ myString:String) -> [String] { return myString.components(separatedBy: "x").sorted().filter { $0.count > 0 }} #1. separatedBy를 x로 하여 분리해주고2. 공백인 문자열은 제거하고 반환하였다.배운 기술 [Day18-1] x 사이의 개수 문제 내 정답 코드import Foundationfunc solution(_ myString:String) -> [Int] { return myString.components(separatedBy: "x").map { $0.count }} #1. x를 sparatedBy로 하여 분리해주고2. count들을 배열의 넣어 반환하였다.배운 기술 이전 1 ··· 30 31 32 33 34 35 36 ··· 62 다음