jeeyeonLIM / coding_test

Let's practice the coding test!
1 stars 0 forks source link

[월간코드챌린지]두 개 뽑아서 더하기 #56

Open jeeyeonLIM opened 3 years ago

jeeyeonLIM commented 3 years ago

문제 설명

제한사항

입출력 예

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

입출력 예 설명

입출력 예 #1

입출력 예 #2

jeeyeonLIM commented 3 years ago

나의 코드

def solution(numbers):
    answer = []
    #numbers = sorted(numbers)
    for i in range(len(numbers)):  
        for j in range(i+1,len(numbers)):
            #print(numbers[i]+numbers[j])
            sum_= numbers[i]+numbers[j]
            if sum_ not in answer:
                answer.append(sum_)
            else: 
                continue
    return sorted(answer)