Home > Learning, math, Problem, Projects/Experiments, Python > Python: Tower of Hanoi

Python: Tower of Hanoi

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 ahradwani.com python projects codeFollow me on Twitter..

By: Ali Radwani

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s