Programmers/프로그래머스-카펫-python

cosmos·2022년 8월 4일
0
post-thumbnail
post-custom-banner

문제

코드

# https://school.programmers.co.kr/learn/courses/30/lessons/42842
# programmers, level2: 카펫, python3
def solution(brown: int, yellow: int) -> list:
    answer, block = [], brown + yellow

    for y in range(3, block):
        x = block // y

        if x * y == block and x >= y and (x-2) * (y-2) == yellow:
            return [x, y]


if __name__ == '__main__':
    print(solution(10, 2))   # [4, 3]
    print(solution(8, 1))    # [3, 3]
    print(solution(24, 24))  # [8, 6]
    print(solution(12, 4))   # [4, 4]
    print(solution(18, 6))   # [8, 3]

결과

출처 & 깃허브

programmers 카펫
github

post-custom-banner

0개의 댓글