내 인생은 개발 중
[프로그래머스] 피로도 - Python 본문
https://school.programmers.co.kr/learn/courses/30/lessons/87946
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
풀이
from itertools import permutations
def solution(k, dungeons):
answer = 0
hp = k
for permute in permutations(dungeons, len(dungeons)):
temp_count = 0
hp = k
for pm in permute:
if hp >= pm[0]:
hp -= pm[1]
temp_count += 1
answer = max(answer, temp_count)
return answer
💡알게 된 점💡
permutation(객체, 몇 개로 조합할 것인지) 으로 사용한다.
permutation은 combination과 달리 순서를 고려하여, 중복 없이 뽑을 경우의 수를 뽑아낸다.
'Algorithm > 프로그래머스' 카테고리의 다른 글
[프로그래머스] 롤케이크 자르기 - Python (0) | 2024.05.19 |
---|---|
[프로그래머스] 피보나치 수 - Python (0) | 2024.05.18 |
[프로그래머스] 다음 큰 숫자 - Python (0) | 2024.05.16 |
[프로그래머스] 숫자의 표현 - Python (0) | 2024.05.14 |
[프로그래머스] 프로세스 - Python (0) | 2024.05.13 |
Comments