## Welcome to BrainDen.com - Brain Teasers Forum

 Welcome to BrainDen.com - Brain Teasers Forum. Like most online communities you must register to post in our community, but don't worry this is a simple free process. To be a part of BrainDen Forums you may create a new account or sign in if you already have an account. As a member you could start new topics, reply to others, subscribe to topics/forums to get automatic updates, get your own profile and make new friends. Of course, you can also enjoy our collection of amazing optical illusions and cool math games. If you like our site, you may support us by simply clicking Google "+1" or Facebook "Like" buttons at the top. If you have a website, we would appreciate a little link to BrainDen. Thanks and enjoy the Den :-)
Guest Message by DevFuse

14 replies to this topic

### #11 EventHorizon

EventHorizon

Senior Member

• VIP
• 512 posts
• Gender:Male

Posted 06 March 2008 - 08:19 PM

An old legend tells of a Hindu temple where the pyramid puzzle might have been used for the mental discipline of young priests. Legend says that at the beginning of time the priests in the temple were given a stack of 64 gold disks, each one a little smaller than the one beneath it. Their assignment was to transfer the 64 disks from one of the three poles to another, with one important condition: a large disk could never be placed on top of a smaller one. The priests worked very efficiently, day and night. When they finished their work, the myth said, the temple would crumble into dust and the world would vanish.

So when the priest will finish their work the world would seize to exist!

Now the question is: When is that?

This question requires a few assumptions....

When is the beginning of time? I'll assume 4000bc to appease the new-earth creationists.

How quickly can the priests move a single disk? I'll assume it takes one second to move a disk and that it doesn't matter the size of the disk.

So, it takes 2^64-1 moves to move the stack.....this is approximately 1.844*10^19.
So that amount in seconds is 3.0744*10^17 minutes
5.1241*10^15 hours
2.13504*10^14 days
5.84542*10^11 years (this used 365.25 as days in a year...I know it is a little off)
584542046.1 millenia
Well.....that's a lot of time.

• 0

### #12 roolstar

roolstar

• Members
• 250 posts
• Gender:Male

Posted 07 March 2008 - 04:38 PM

As for the window closing. I wrote it to be run from the dos prompt (it is easier to do batch processing that way). The program finishes once the answer is printed, but you could always add in a pause of some sort (two getchar()'s ? or System("pause")) if you can recompile the code.
When running from the dos prompt you can also just give it the number of towers and disks on the commandline (eg, "hanoi.exe 4 6").

As for not being able to follow the code.....I assume you mean the C++ code and not the pseudocode...here's a bit of a walkthrough as to what it is doing.

* deep breath *

...

Hope that helps....

It does!!

Thanks EH for your efforts, I can see this took some time...
• 0

### #13 roolstar

roolstar

• Members
• 250 posts
• Gender:Male

Posted 07 March 2008 - 04:41 PM

This question requires a few assumptions....

When is the beginning of time? I'll assume 4000bc to appease the new-earth creationists.

How quickly can the priests move a single disk? I'll assume it takes one second to move a disk and that it doesn't matter the size of the disk.

So, it takes 2^64-1 moves to move the stack.....this is approximately 1.844*10^19.
So that amount in seconds is 3.0744*10^17 minutes
5.1241*10^15 hours
2.13504*10^14 days
5.84542*10^11 years (this used 365.25 as days in a year...I know it is a little off)
584542046.1 millenia
Well.....that's a lot of time.

So we're safe for now! Pfuu...

I even heard another twist in the legend saying that every VISITOR to the temple has to move one disk, and when all of them are on the 3rd pole, THE END!

So this would take a bit more time....
• 0

### #14 EventHorizon

EventHorizon

Senior Member

• VIP
• 512 posts
• Gender:Male

Posted 07 March 2008 - 09:55 PM

It does!!

Thanks EH for your efforts, I can see this took some time...

YW. It didn't take all that much time actually....I'm a Computer Science grad.

It was a problem I had thought a bit about before...and it was kinda fun to decide how to implement it in C++ and then to find the answer. It's also nice to know someone else was interested in it too.
• 0

### #15 redshift

redshift

Junior Member

• Members
• 50 posts

Posted 07 March 2008 - 10:49 PM

I had a variant of this as a kid. It was nesting pyramids with a prize under the smallest (you could only put a pyramid on a smaller pyramid). I solved it once and never felt it was worth the time to ever solve it again
• 0

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users