프로그래머스 - 카펫 feat. 완전탐색
·
Algorithm/programmers
import Foundationfunc solution(_ brown:Int, _ yellow:Int) -> [Int] { let sum = brown + yellow let b = brown / 2 var answer: [Int] = [] for i in (3...b) { if sum % i == 0 { for j in (3...b) { if i*j == sum && i >= j && (i-2)*(j-2)==yellow { answer = [i, j] } } } } return answer}