<jupyter_start><jupyter_text>algorithm<jupyter_code>def get_rods(move, towers, left, middle, right):
    if towers:
        if (move << 1) & (1 << towers):
            right.append(towers)
            get_rods(move, towers - 1, middle, left, right)
        else:
            left.append(towers)
            get_rods(move, towers - 1, left, right, middle)
def get_move(towers, left, middle, right):
    if not towers:
        return 0
    if not left or right and left[0] < right[0]:
        move = 1 << (towers - 1)
        return move + get_move(towers - 1, middle, left, right[1:])
    else:
        return get_move(towers - 1, left[1:], right, middle)
def hanoi(towers):
    for i in range(2 ** towers):
        rods = [], [], []
        get_rods(i, towers, *rods)
        move = get_move(towers, *rods)
        print('{:2} moves -- {} {} {}'.format(move, *rods))<jupyter_output><empty_output><jupyter_text>run<jupyter_code>hanoi(2)
hanoi(3)
hanoi(4)
hanoi(5)<jupyter_output>0 moves -- [5, 4, 3, 2, 1] [] []
 1 moves -- [5, 4, 3, 2] [] [1]
 2 moves -- [5, 4, 3] [2] [1]
 3 moves -- [5, 4, 3] [2, 1] []
 4 moves -- [5, 4] [2, 1] [3]
 5 moves -- [5, 4, 1] [2] [3]
 6 moves -- [5, 4, 1] [] [3, 2]
 7 moves -- [5, 4] [] [3, 2, 1]
 8 moves -- [5] [4] [3, 2, 1]
 9 moves -- [5] [4, 1] [3, 2]
10 moves -- [5, 2] [4, 1] [3]
11 moves -- [5, 2, 1] [4] [3]
12 moves -- [5, 2, 1] [4, 3] []
13 moves -- [5, 2] [4, 3] [1]
14 moves -- [5] [4, 3, 2] [1]
15 moves -- [5] [4, 3, 2, 1] []
16 moves -- [] [4, 3, 2, 1] [5]
17 moves -- [1] [4, 3, 2] [5]
18 moves -- [1] [4, 3] [5, 2]
19 moves -- [] [4, 3] [5, 2, 1]
20 moves -- [3] [4] [5, 2, 1]
21 moves -- [3] [4, 1] [5, 2]
22 moves -- [3, 2] [4, 1] [5]
23 moves -- [3, 2, 1] [4] [5]
24 moves -- [3, 2, 1] [] [5, 4]
25 moves -- [3, 2] [] [5, 4, 1]
26 moves -- [3] [2] [5, 4, 1]
27 moves -- [3] [2, 1] [5, 4]
28 moves -- [] [2, 1] [5, 4, 3]
29 moves -- [1] [2] [5, 4, 3]
30 moves -- [1] [] [5, 4, 3, 2]
31 moves -- [] [] [5, 4, 3, 2, 1]
{'fraction_non_alphanumeric': 0.2464430894308943, 'fraction_numerical': 0.11839430894308943, 'mean_word_length': 2.2384868421052633, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '5286', 'license': 'MIT', 'n_tokens_mistral': 1043, 'n_tokens_neox': 901, 'n_words': 308, 'path': '100days/day 61 - hanoi tower II.ipynb', 'repo_name': 'gopala-kr/ds-notebooks', 'size': '1968'}