Python/😈 99클럽 코테 스터디 4기 TIL

99클럽 코테 스터디 21일차 TIL - 완점탐색 (프로그래머스- 카펫)

쿄코코 2024. 11. 18. 01:28
반응형

https://school.programmers.co.kr/learn/courses/30/lessons/42842

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

  • 오늘의 학습 키워드 : 완전탐색
1. 약수 구하기 : total = 24라면 약수는 1, 2, 3, 4, 6, 8, 12, 24
2. if (width - 2) * (height - 2) == yellow : return [width, height]
  • 공부한 내용 
    def solution(brown, yellow):
        answer = []
        total = brown + yellow
        for height in range(1,int(total**0.5)+1):
            if total%height==0:
                width = total//height
                if (width - 2) * (height - 2) == yellow:
                    return [width, height]
  • 오늘의 회고

 

 

반응형