Post

์นดํŽซ lv2

๐ŸŒˆ๋ฌธ์ œ ๋งํฌ

Desktop View

Desktop View

๋‘˜๋ ˆ ๊ณต์‹ (๊ฒ‰ ํ…Œ๋‘๋ฆฌ๋งŒ ๊ณ„์‚ฐ)

(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

Desktop View

Desktop View

Desktop View




์ฐธ๊ณ 

https://bingbing-study.tistory.com/198

This post is licensed under CC BY 4.0 by the author.
3D GIF