전체 글 (184) 썸네일형 리스트형 [Day5-2] 등차수열의 특정한 항만 더하기 문제 내 정답 코드 import Foundation func solution(_ a:Int, _ d:Int, _ included:[Bool]) -> Int { var result = 0 for i in 0.. [Day5-1] 코드 처리하기 문제 내 정답 코드 import Foundation func solution(_ code:String) -> String { var ref = "" var mode = false var idx = 0 for char in code { if !mode { if char == "1" { mode = true } else { if idx.isMultiple(of: 2) { ref += String(char) } } } else { if char == "1" { mode = false } else { if !idx.isMultiple(of: 2) { ref += String(char) } } } idx += 1 } return ref == "" ? "EMPTY" : ref } # 1. 문자열을 순회하며 각 조건.. [Day4-5] flag에 따라 다른 값 반환하기 문제 내 정답 코드 import Foundation func solution(_ a:Int, _ b:Int, _ flag:Bool) -> Int { return flag ? a + b : a - b } # 1. falg의 역할정도를 알려주는 간단한 문제 배운 기술 이전 1 ··· 52 53 54 55 56 57 58 ··· 62 다음