Skip to content

Instantly share code, notes, and snippets.

@aliwo
Created October 1, 2019 06:13
Show Gist options
  • Save aliwo/39135f75e718048a75257735ccaa5b30 to your computer and use it in GitHub Desktop.
Save aliwo/39135f75e718048a75257735ccaa5b30 to your computer and use it in GitHub Desktop.
# 한 줄 짜리 솔루션 해석
def solution(t, l = []):
if not t: # 탈출 조건. 삼각형을 전부 소모한다.
return max(l)
result = []
for x, y, z in zip([0]+l, l+[0], t[0]): # [0] + l = 0 더하기 리스트
# zip 은 리스트를 n 개 받아서 각 리스트 마다 foreach 를 돌아줘요
# for a, b, c in zip(A, B, C) 이면 a 는 A의 요소, b 는 B의 요소, c 는 C의 요소
result.append(max(x, y) + z) # result 에 하나씩 더함
return solution(t[1:], result) # t[1:] 은 리스트 t의 0번째 요소를 절삭한 리스트
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment