Skip to content

Commit ee548e9

Browse files
committed
[PGS]#12914.멀리뛰기/lv2/실패
ttps://school.programmers.co.kr/learn/courses/30/lessons/12914?language=python3
1 parent 87180a0 commit ee548e9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Hongjoo/lv2/멀리뛰기.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
answer = 0
2+
def solution(n):
3+
4+
def backtracking(path,lv):
5+
# 재귀 종료
6+
global answer
7+
if lv >= len(path):
8+
if sum(path)==n :
9+
answer += 1
10+
# print(f"{lv} : {path} >{answer}")
11+
return 0
12+
#자식 노드 이동
13+
for x in [1,2] :
14+
if sum(path) + x <= n :
15+
path[lv] = x
16+
backtracking(path , lv+1)
17+
# backtracking
18+
path[lv] = 0
19+
20+
for m in range(1,n+1) :
21+
backtracking([0]*m , 0)
22+
return answer%1234567

0 commit comments

Comments
 (0)