# 사실 하노이는 2 ^ 원반의 갯수 - 1을 해서 프린트 해주면
# 이런식으로 리스트는 사용하지 않아도 됩니다.(쓴 이유 : 그냥..)

K = int(input())
print_list = []

def hanoi(num, a, b, c, print_list):
    if(num == 1):
        print_list.append([a, c])
        return None
    
    hanoi(num - 1, a, c, b, print_list)
    print_list.append([a, c])
    hanoi(num - 1, b, a, c, print_list)
hanoi(K, 1, 2, 3, print_list)

print(len(print_list))
for a, b in print_list:
    print('{} {}'.format(a, b))

 

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 3052번(python)  (0) 2019.07.03
백준 10818번(python)  (0) 2019.07.03
백준 2447번(python)  (4) 2019.06.28
백준 10872번(python)  (0) 2019.06.27
백준 10870번(python)  (0) 2019.06.27


import sys

num = int(input())

def star(i, j):
    while(i != 0):
        # 몫이 1인 경우
        if(i % 3 == 1 and j % 3 == 1):
            sys.stdout.write(' ')
            return None
        # 3으로 나누어서 위의 if문에 걸리면 그 부분도 빈칸 처리
        i = i // 3
        j = j // 3
    sys.stdout.write('*')

for i in range(num):
    for j in range(num):
            star(i, j)
    sys.stdout.write('\n')

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 10818번(python)  (0) 2019.07.03
백준 11729번(python)  (0) 2019.06.28
백준 10872번(python)  (0) 2019.06.27
백준 10870번(python)  (0) 2019.06.27
백준 15596번(python)  (0) 2019.06.27


num = int(input())
res = 1

def factorial(res, count):
    if(num == 0):
        return print(1)
    else:
        res *= count

        if(count == num):
            return print(res)
        
        return factorial(res, count + 1)
factorial(res, 1)

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 11729번(python)  (0) 2019.06.28
백준 2447번(python)  (4) 2019.06.28
백준 10870번(python)  (0) 2019.06.27
백준 15596번(python)  (0) 2019.06.27
백준 2562번(python)  (0) 2019.06.27


num = int(input())

def fibonach(a, b, count):
    if(num == 0):
        print(a)
    elif(num == 1):
        print(b)
    else:  
        c = a + b

        if(count == num):
            return print(c)

        return fibonach(b, c, count + 1)
fibonach(0, 1, 2)

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 2447번(python)  (4) 2019.06.28
백준 10872번(python)  (0) 2019.06.27
백준 15596번(python)  (0) 2019.06.27
백준 2562번(python)  (0) 2019.06.27
백준 10951번(python)  (0) 2019.06.27


def solve(a):
    return sum(a)

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 10872번(python)  (0) 2019.06.27
백준 10870번(python)  (0) 2019.06.27
백준 2562번(python)  (0) 2019.06.27
백준 10951번(python)  (0) 2019.06.27
백준 10952번(python)  (0) 2019.06.27