vishal8113 / Hacktoberfest-2024

This repository is waiting for your contribution. If you have not contribute in hacktober fest till now. You can start contributing in open source from here.
3 stars 25 forks source link

Added Tower of Hanoi #33

Closed sehajbansal closed 22 hours ago

sehajbansal commented 23 hours ago

There are three rods (or pegs) and n disks of different sizes that can slide onto any rod. Initially, all the disks are stacked on one rod in decreasing order of size from top to bottom (i.e., the smallest disk is on the top, and the largest disk is on the bottom).

The objective is to move the entire stack to another rod, following these three rules:

  1. Only one disk can be moved at a time.
  2. Each move consists of taking the top disk from one of the rods and placing it on another rod.
  3. No larger disk may be placed on top of a smaller disk.