💬 문제
https://school.programmers.co.kr/learn/courses/30/lessons/42842
💬 Idea
- 노란색을 직사각형으로 채울 수 있는 가로, 세로를 찾기 위해 반복문을 돌면서 나머지가 0인 경우를 찾는다.
- 만약 (yx * 2) + (i * 2) + 4 가 브라운의 값과 같다면 target이므로 break한다.
💬 풀이
import Foundation
func solution(_ brown:Int, _ yellow:Int)->[Int]{varres:[Int]=[]if yellow ==1{return[3,3]}foriin1...yellow /2+1{if yellow % i ==0{letyx= yellow / i
letans=(yx *2)+(i *2)+4if ans == brown {
res =[yx +2, i +2]break}}}return res
}
💬 문제https://school.programmers.co.kr/learn/courses/30/lessons/42842
💬 Idea💬 풀이