def solution(brown, yellow):
answer = []
sum_value = brown + yellow
for l in range(3, brown):
if sum_value % l == 0:
w = sum_value // l
if w >= l:
for i in range(1, w):
if yellow == (w - i) * (l - i):
answer.append(w)
answer.append(l)
return answer
return answer
brown
테두리 안에 yellow
가 있으려면 세로 길이는 최소 3 이상이 되어야 함brown
과 yellow
의 모든 개수를 담을 수 있는 가로 길이를 찾음yellow
가 알맞게 들어갈 수 있는지 1씩 내부 yellow
공간을 줄이면서 확인