[프로그래머스/Python]없는 숫자 더하기

Jimin_Note·2022년 5월 14일
0
post-thumbnail

💾없는 숫자 더하기

월간 코드 챌린지 시즌3

📍문제 설명
0부터 9까지의 숫자 중 일부가 들어있는 정수 배열 numbers가 매개변수로 주어집니다. numbers에서 찾을 수 없는 0부터 9까지의 숫자를 모두 찾아 더한 수를 return 하도록 solution 함수를 완성해주세요.

📍입출력

numbersresult
[1,2,3,4,6,7,8,0]14
[5,8,4,0,6,7,9]6

📍내 답안

def solution(numbers):

    num=[1,2,3,4,5,6,7,8,9]
    a = list(set(num) - set(numbers)) #차집합
    return sum(a) #합계
profile
Hello. I'm jimin:)

0개의 댓글