์นดํซ lv2
๐๋ฌธ์ ๋งํฌ
๋๋ ๊ณต์ (๊ฒ ํ ๋๋ฆฌ๋ง ๊ณ์ฐ)
(2*๊ฐ๋ก) + 2(์ธ๋ก-2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def solution(brown, yellow):
answer = []
a,b = 0,3 # a(๊ฐ๋ก) b(์ธ๋ก)
calculator= (brown + 4)//2
while True: # ์กฐ๊ฑด๋ค์ด ์ฐธ์ผ๋์ ๊ณ์ ๋ฐ๋ณต
a = calculator - b
if a < b: # ์ด๊ฑฐ ์๋ํ๋ฉด ๋ฌธ์ ์์ ๊ฐ๋ก๊ฐ ์ธ๋ก๋ณด๋ค ๊ฐ๊ฑฐ๋ ๊ธธ๋ค๊ณ ํจ
break
if a >= b: #์กฐ๊ฑด์ ๋ง์ผ๋ฉด
if a*b - brown == yellow:
answer.append(a)
answer.append(b)
break
b += 1
return answer
์ฐธ๊ณ
This post is licensed under CC BY 4.0 by the author.