[coding test] Baekjoon_level 10_재귀-2
2021. 6. 8. 22:07ㆍPython/코딩 테스트
Ver. Jupyter Notebook (Anaconda3)
▶ coding test_Baekjoon_level 10_재귀-2
- 백준: baekjoon
- 코딩 및 결과: github
JeongJaeyoung0/coding_test
코딩테스트. Contribute to JeongJaeyoung0/coding_test development by creating an account on GitHub.
github.com
2021.06.08
# coding test_Baekjoon_level 10_재귀-2
# 11729 (히노이 탑 이동 순서)-1
def h(a,b,c):
if a==1:
return [[b,c]]
return h(a-1,b,6-b-c)+[[b,c]]+h(a-1,6-b-c,c)
a=int(input())
p=h(a,1,3)
print(2**a-1)
for i in range(len(p)):
print(p[i][0],p[i][1])
# 11729 (히노이 탑 이동 순서)-2
def h(a,b,c):c>1!=h(a,a^b,c-1);print(a,b);c>1!=h(a^b,b,c-1)
c=int(input());print(2**c-1);h(1,3,c)
'Python > 코딩 테스트' 카테고리의 다른 글
[coding test] Baekjoon_level 11_브루트 포스-2 (0) | 2021.06.10 |
---|---|
[coding test] Baekjoon_level 11_브루트 포스-1 (0) | 2021.06.09 |
[coding test] Baekjoon_level 10_재귀-1 (0) | 2021.06.07 |
[coding test] Baekjoon_level 9_기본 수학 2-3 (0) | 2021.06.06 |
[coding test] Baekjoon_level 9_기본 수학 2-2 (0) | 2021.06.05 |