๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • What would life be If we had no courage to attemp anything?
Problem Solving/PROGRAMMERS

[python]ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - ์‚ผ์ด์‚ฌ

by DevIseo 2022. 10. 25.

[Python]ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - ์‚ผ์ด์‚ฌ

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

 

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.

programmers.co.kr

from itertools import combinations
def solution(number):
    answer = 0
    combis = list(combinations(number, 3))
    for combi in combis:
        if sum(combi) == 0:
            answer+=1
    return answer

๋Œ“๊ธ€