Feb. 14, 2024

Mastering Tower of Hanoi

8:50 AM

It started on Monday, sometime in the morning. I have this brain training app on my phone and one of the games on there is the Tower of Hanoi. The Tower of Hanoi is a puzzle where there are 3 rods and multiple disks of varying sizes. The goal is to move all the disks to the rightmost side, but the rule is that smaller discs can only be put on top of larger disks, so you can't put a larger disk on top of a smaller one. This limits movement, so that you have to do a sort of shuffling to move the disks around.

I played a few levels a month ago, and was just playing by intuition. I spent a few minutes on it, but I didn't really analyze or know how to solve it that well. My first impression was that I thought it was a difficult puzzle. I knew there'd probably be a way to always solve it, but I thought that was something I wouldn't be able to discover or learn on my own, not even with a tutorial. So I only played it for a few minutes, completing 9 levels I think, some of them being perfect.

There's 30 levels in this game, and it's basically the Tower of Hanoi with different starting setups. After completing each stage, it tells you the time it took and the number of moves. It would also tell you how well you did against other users, which I think is a fake statistic; I think the number is generated through a formula, and that there isn't actually people's times and moves being compared. Anyway I thought this was interesting.

On Monday, for some reason, even though it's probably been over a month since I last played Tower of Hanoi, I decided to play it yet again. This time, I analyzed my moves a little. I had thoughts like, if I want to move this piece here, how would I do that? And then I started noticing some patterns and some techniques. There's only 3 rods, only two I can transfer to, so that makes it a binary choice of where I should put each rod, just one or the other. If I wanted to move a stack of disks from one rod to another, and there is an odd number of disks, I should move the first disk to that rod first. If I wanted to move a stack onto another rod, and there's an even number of disks, I have to move the disk to the other rod first.

Just learning that, through a combination of intuiting and analyzing, I figured out the entirety of the Tower of Hanoi. I never watched any tutorials on it, or any guides or anything. I learned a perfect way to solve it every time, on my own. It honestly took maybe less than an hour to figure that all out by the way. The first time I played it and I wasn't thinking, I never solved it. After just analyzing it for around an hour, I solved the whole thing. This was on Monday morning.

Having this knowledge, I was able to complete any stage at record time, and often without any mistakes or extraneous moves. I cleared the last 10 or so levels, making no mistakes, in very fast times, around a third or so of the time the average took, after seeing a puzzle for the first time. When I first start a level, it takes me about a minute to think about the best possible moves, since I want to complete it in the exact number of moves needed. Then I just solve it, and it's easy.

Now this doesn't mean I'd be any good at programming the solution to this. I think recursion is used here as the optimal solution, but I am not at the level yet, well at least I don't think I am, where I am able to do that. Obviously it would be a very proud moment if I did get to that point, and maybe some day in the future I'll be there, but right now that's a distant dream.

Anyway, on Tuesday, I beat the former 2021 Guinness World Record for completing Tower of Hanoi with 6 disks. The former record was 33 seconds, and I was able to complete it in 31 seconds. Also, I beat the whole game too, including a 9 disk puzzle, perfectly, on my first try. I completed I think basically all of the last 10 or so stages without any mistakes. Meaning that once I reached the end, it told me "You made the exact number of moves required. Well done!" The starting setup is always a little different, and you have to think of an optimal way to solve it, it takes me around a minute to think of that, and then you make the moves. So there's still some difficulty, and I was able to solve them all on my first try.

Anyway I'm just very proud of this, that I was able to figure out and solve this difficult puzzle. And yeah I think I wrote down the entire strategy of how to solve it here. I really don't think it's much more than that, just counting how many pieces you have to move, and if it's odd or even then place it in a certain rod first. It's not a very complicated puzzle once you figure out the basics. I think a few steps ahead too like "I want to move this 8 piece here, to do that I have to move this 7 piece there, to do that, I have to move this 6 piece there," and so on, so it's not so easy, but I think it is simple.

To me, the whole puzzle is solved. I can solve it in the optimal amount of moves, in a time that is around a third of what people take normally. I can solve any setup too, I proved that by beating all 30 levels. Some of these levels take 500+ steps to solve, and I'm able to get them perfectly. I got them perfectly on my first try.

Anyway that was my experience mastering and solving the Tower of Hanoi puzzle. I should probably make a tutorial video on how I solve it, while I still remember. I think this is a useless skill and ability, so in a few months, once I stop playing this, of course I'll forget how to solve this probably. I'll have to come up with the strategy again, and so on. But right now I'm at the peak. I can literally solve any setup perfectly. Perfectly. I think that word requires emphasis, because imagine making 500+ moves and each move being perfect and optimal. That is hard, but I'm able to do it right now. I'm at that level right now. But in a few months? I won't be. So maybe I should make videos of it while I can.

Written by JustMegawatt

194 Views
Log in to Like
Log In to Favorite
Share on Facebook
Share on Twitter
Comments

You must be signed in to post a comment!