EunGyeongKim

[월간코드]없는 숫자 더하기 본문

코딩테스트/programmers

[월간코드]없는 숫자 더하기

EunGyeongKim 2022. 9. 21. 17:17

더 많은 코드 (https://github.com/EunGyeongKim/TIL)

 

GitHub - EunGyeongKim/TIL: Today I Learne

Today I Learne. Contribute to EunGyeongKim/TIL development by creating an account on GitHub.

github.com

문제 링크

 

프로그래머스

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

programmers.co.kr

1. 문제 설명

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


2. 제한사항

  • 1 ≤ numbers의 길이 ≤ 9
    • 0 ≤ numbers의 모든 원소 ≤ 9
    • numbers의 모든 원소는 서로 다릅니다.

3. 입출력 예

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

4. 코드

def solution(numbers):
    answer = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
    for i in numbers:
        answer.remove(i)
    return sum(answer)
Comments