DevYoon
[ํ๋ก๊ทธ๋๋จธ์ค] ์นดํซ (Python) ๋ณธ๋ฌธ
link ๐ https://programmers.co.kr/learn/courses/30/lessons/42842
1๏ธโฃ yellow์ ์ฝ์๋ฅผ ๊ตฌํด divisor์ ๋ด์ ์ฃผ์๋ค. (yellow์ ๋๋น์ ๋์ด)
2๏ธโฃ ์ฝ์ ๋ฆฌ์คํธ์์ ํ๋์ฉ ๋ฝ์ ๋๋น*2+๋์ด*2+4๊ฐ brown๊ณผ ๊ฐ์ผ๋ฉด(์๋ ์ด๋ฏธ์ง ์ฐธ๊ณ ) answer๋ก ๋๋น์ ๋์ด์ ๊ฐ๊ฐ 2์ฉ ๋ํด ๋ฃ์ด์ฃผ์๋ค.
def solution(brown, yellow):
answer = []
divisor = []
for num in range(1, yellow+1):
if yellow%num == 0:
if num >= yellow//num:
divisor.append([num, yellow//num])
for comb in divisor:
if comb[0]*2+comb[1]*2+4 == brown:
answer = [comb[0]+2, comb[1]+2]
return answer