Archive for September 15, 2021

Python: Tower of Hanoi

September 15, 2021 Leave a comment

Learning : Python
Subject: Write a Function to Solve Tower of Hanoi Problem

Intoduction: Tower Of Hanoi is Puzzle Game that has three Vertical Sticks/Pegs Named A, B, C (3 Towers) and we have n number of disks different in diameter soted on top of each other (Large to Small) in Tower A. The Gall is to move all the disks from (A) to (C).

 # Tower of Hanoi Puzzel

    Project Name: Tower of Hanoi
    By: Ali Radwani
    Date: 13.6.2021
     d  : Number of Desk
     fs : From Stick
     ts : To Stick
     bs : Buffer Stick

import os

def hanoi_t(d, fs, bs, ts): 
    if d ==1 : 
        print("\n   Move Desk 1 From {} To {}".format(fs,ts)) 

        print("   Move Desk {} From {} To {}".format(d,fs,ts)) 
        print("   Move Desk {} From {} To {}".format(d,fs,ts))
print('\n\n   This is Tower Of Hanoi Project')
print('   We are Solving a Three Desk Tower Named 1, 2 and 3, with Three Sticks Named A, B and C ')
print('\n   Start Solving ...')

python project code Tower of Hanoi ali radwani

..:: Have Fun with Coding ::.. 🙂

To Download my Python code (.py) files Click-Here

ali radwani python projects codeFollow me on Twitter..

By: Ali Radwani