동캄의 코딩도장

프로그래머스 level1 [삼총사] 파이썬 본문

코테/프로그래머스

프로그래머스 level1 [삼총사] 파이썬

동 캄 2023. 4. 4. 10:36

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

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

# 프로그래머스 level1 삼총사
from itertools import combinations
def solution(number):
    answer = 0
    combi=combinations(number,3)
    for c in combi:
        if sum(c)==0:
            answer+=1
    return answer

combinations 라이브러리를 이용하여 해결하였다.