Skip to main content

Questions tagged [tower-of-hanoi]

A puzzle to build the Tower of Hanoi on an area of 3 rods with a number of disks of varying size.

Filter by
Sorted by
Tagged with
2 votes
3 answers
145 views

Solving the Towers of Hanoi problem in Python by using 3 stacks

I am attaching my code to solve the Hanoi problem. What do you think? Would you change something? I am attaching the instructions for solving the problem, does the code solve the question? In the ...
SHOVAL's user avatar
  • 51
3 votes
2 answers
412 views

Tower of Hanoi in Racket

I'm in the early stages of learning Racket, and decided to have a go at the tower of Hanoi. I did this without any reference whatsoever, so everything is up for review, including the algorithm as well ...
Avrohom Yisroel's user avatar
5 votes
1 answer
2k views

Tower of Hanoi without recursion

Hi I am pretty new to programming and I would like you to give me some feedback about my code, how does it look, what could be better. Thank you. ...
Kashee's user avatar
  • 61
3 votes
2 answers
654 views

Script for Python Hanoi Tower OOP

Is my Python Script to play Hanoi Tower respectful of OOP spirit? I have difficulties to create meaningful classes so I started an easy project. Here is one class at the plateau level and then a ...
Kerdiorp's user avatar
  • 139
2 votes
1 answer
156 views

Interactive Tower of Hanoi

I created this program some time ago. It shows you how to solve tower of hanoi for n disks, step by step. Here's the code: ...
Sriv's user avatar
  • 2,740
12 votes
2 answers
2k views

Tower of Hanoi Recursive Implementation using Python with OOP

I have just finished a small program for Tower of Hanoi using recursion. I did it to practice OOP which I recently learnt. It took me about 2 hours to research about the recursive algorithm and write ...
Oliver H's user avatar
  • 123
11 votes
1 answer
203 views

Slow image generation

I build a Tower of Hanoi solver which print the solution as an image It works as expected but generating the image is relatively slow compared to the time to calculate the answer. Here is the code: ...
wqeqwsd's user avatar
  • 113
2 votes
2 answers
314 views

Iterative version of Hanoi Tower exercise

I just finished a iterative version of Hanoi Tower. This is how the algorithm works: I'm trying to find a method to delete the goto instruction. Any tips? ...
Robert's user avatar
  • 161
4 votes
2 answers
1k views

Iterative Implementation of Towers of Hanoi

Here is an implementation of Towers of Hanoi based on few observed patterns1 from the easier recursive solution: ...
Ziezi's user avatar
  • 1,174
7 votes
1 answer
788 views

Python 2.7 Tower of Hanoi game with ASCII graphics

The game generates a fixed, "animated" game board via ASCII characters that is reprinted and cleared after each valid move. The format of the input for making moves is described in the script. You ...
Stinky Peterson's user avatar
4 votes
2 answers
580 views

Tower of Hanoi solver in Ruby

Solved the classic Tower of Hanoi problem in Ruby, using recursion. Would love your feedback on this. ...
FloatingRock's user avatar
0 votes
1 answer
176 views

Tower of Hanoi move method

So I have some code which solves the tower of hanoi problem. The code that I have written is pretty clunky and seems to repeat itself multiple times. Was just wondering if there was some way of ...
Small Legend's user avatar
2 votes
1 answer
2k views

Tower of Hanoi: graphical representation of optimal solution

I wrote a program to show graphically the solution of the problem of the Tower of Hanoi. Here is a video of an example run. The logic of the solving is taken from StackOverflow (see links in ...
Caridorc's user avatar
  • 27.5k
8 votes
2 answers
14k views

Tower of Hanoi (without recursion)

I came across an interesting method of solution for the Tower of Hanoi puzzle and wrote a short version of it as a programming exercise. The program produces the correct results but I have two ...
Verbatim's user avatar
  • 351
7 votes
1 answer
285 views

Towers of Hanoi redux

Inspired by Mayur Kulkarni's question this morning, I decided to post some code for the classic Towers of Hanoi problem, but this time in C++. Since this is fairly "textbook" kind of task, all ...
Jerry Coffin's user avatar
  • 33.6k
3 votes
1 answer
1k views

Tower of Hanoi simulation

I've just implemented a simulation of tower of hanoi in Java. Any suggestions are welcomed. Here's my code: ...
Mayur Kulkarni's user avatar
7 votes
4 answers
2k views

Towers of Hanoi

I am just learning how to code in Ruby now with no prior experience. This is 3 towers of Hanoi where the user selects where to choose from and where to go with each disc, and not to have a bigger disc ...
Jgoo83's user avatar
  • 171
6 votes
1 answer
3k views

Implementation of Tower of Hanoi iterative procedure

I have been working last night on implementing Tower of Hanoi without using recursion. I have found an algorithm on Wikipedia about the same topic here. I have implemented it and it's working fine (...
cracknut's user avatar
7 votes
1 answer
5k views

Solving the Reve's puzzle

I'm trying to solve the Reve's puzzle (a variant of the Tower of Hanoi puzzle with four pegs). This is what I've come up with so far: ...
Sc4r's user avatar
  • 173
7 votes
1 answer
3k views

Tower of Hanoi solver

Requesting code review, best practices, optimizations for this solution to the Tower of Hanoi problem. ...
JavaDeveloper's user avatar
-1 votes
1 answer
2k views

Hanoi Towers solver [closed]

I've made an algorithm solving Hanoi Tower puzzles, for n disks and m pegs. It uses lists as pegs, each list's element contains disks array - {0, 0, 0} means the ...
user2251921's user avatar
8 votes
1 answer
3k views

Towers of Hanoi in Haskell

Of course the recursive version is trivial: ...
Landei's user avatar
  • 6,982