https://school.programmers.co.kr/learn/courses/30/lessons/181927
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
문제
코드
def solution(num_list):
# n이 n-1보다 크면 -> n-(n-1)을 배열에 추가하여 return
# n이 n-1보다 크지 않다면 -> n*2를 배열에 추가하여 return
a = len(num_list)
if num_list[a-1] > num_list[a-2] :
num_list.append(num_list[a-1] - num_list[a-2])
else :
num_list.append(num_list[a-1] * 2)
return num_list
'10 어 Ga zi (이모저모고모) > 코딩테스트' 카테고리의 다른 글
[프로그래머스] Python - Lv.0 수 조작하기 2 (2) | 2024.04.22 |
---|---|
[프로그래머스] Python - Lv.0 수 조작하기 1 (0) | 2024.04.22 |
[프로그래머스] Python - Lv.0 이어 붙인 수 (0) | 2024.04.22 |
[프로그래머스] Python - Lv.0 원소들의 곱과 합 (0) | 2024.04.22 |
[프로그래머스] Python - Lv.0 주사위 게임 2 (0) | 2024.04.22 |