(자랑 주의!) 오늘의 코드

타샤's 월드·2022년 8월 12일
0

프로그래머스 두개 뽑아서 더하기

문제설명:

정수 배열 numbers가 주어집니다. numbers에서 서로 다른 인덱스에 있는 두 개의 수를 뽑아 더해서 만들 수 있는 모든 수를 배열에 오름차순으로 담아 return 하도록 solution 함수를 완성해주세요.

input->[2,1,3,4,1]
output->[2,3,4,5,6,7]

'''내 코드'''
from itertools import combinations

def solution(numbers):
    return sorted(list(set(map(sum, combinations(numbers,2)))))
profile
그때 그때 꽂힌것 하는 개발블로그

0개의 댓글