[프로그래머스] 체육대회 (Python)

yuuforest·2023년 8월 5일

알고리즘

목록 보기
2/8
post-thumbnail

프로그래머스 문제 풀이 - PCCP 모의고사 #1

⭐️파이썬 알고리즘 스터디 공통 문제⭐️

📰 문제


문제 확인 🏃


💡 입출력 예제


[[40, 10, 10], [20, 5, 0], [30, 30, 30], [70, 0, 70], [100, 100, 100]]

>> 210
[[20, 30], [30, 20], [20, 30]]

>> 60

💬 풀이


🎵 첫번째 풀이

import itertools

def solution(ability):
    answer = 0
    game = len(ability[0])

    npr = list(itertools.permutations(ability, game))

    for g in npr:
        count = 0
        for i in range(game):
            count += g[i][i]
        answer = max(answer, count)

    return answer

✒️ 생각


profile
🐥 Backend Developer 🐥

0개의 댓글