<jupyter_start><jupyter_text>When moving 3 disks from A to C, we move the top two disks to B and then the bottom disk to C. More generally, when moving n disks from A to C we move n-1 disks to B; we then move the base disk from A to C and then move the stack of n-1 on B to C .<jupyter_code># We have 3 towers A, B and C or 3 Stacks

A = [14,13,12,11,10,9,8,7,6,5,4,3,2,1]
B = []
C = []
# According to our rules, if we want to move all disks 3,2 and 1 from A to C, we first move two disks from A to B. We then move
# the base disk from A to C and then the stack of two from B to C
count = 0
def towers_of_hanoi(A,B,C,n):
    global count 
    
    if n == 1:
        disk = A.pop()
        C.append(disk)
        count +=1    
    else:
        
        towers_of_hanoi(A,C,B,n-1)
        
        towers_of_hanoi(A,B,C,1)
        
        towers_of_hanoi(B,A,C,n-1)
    return count   
       
towers_of_hanoi(A,B,C,14)
A
B
C<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09309623430962342, 'fraction_numerical': 0.036610878661087864, 'mean_word_length': 2.4301075268817205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '392164', 'license': 'MIT', 'n_tokens_mistral': 398, 'n_tokens_neox': 369, 'n_words': 147, 'path': '2. Jupyter Notebooks/9.6.8_Hanoi.ipynb', 'repo_name': 'Menosse/python-programmer', 'size': '956'}