Sythe.Org Forums     Register     FAQ     Members List     Calendar     Mark Forums Read    
 
Sythe.Org Forums  
   Runescape Gold

Sythe.org — A Virtual Goods Trading Hub

Make real cash! buying and selling in-game items.

We have a no-scam policy.

You can make thousands playing your favourite games here at Sythe.org.

Just sign up an account and follow the rules!


Take me to

Runescape Markets

Other Game Markets

Support Center

Register an Account

Close
BotInc C++ Challenges
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 08-15-2011, 10:06 AM
BotsInc's Avatar
Member
 
Join Date: Aug 2011
Posts: 78
Default BotInc C++ Challenges

First challenge:

The ancient folklore behind the “Towers of Hanoi” puzzle is quite well known. A more recent legend tells us that once the Brahmin monks discovered how long it would take to finish transferring the 64 discs from the needle which they were on to one of the other needles, they decided to find a faster strategy and be done with it.

The Four Needle (Peg) Tower of Hanoi
One of the priests at the temple informed his colleagues that they could achieve the transfer in single afternoon at a one disc-per-second rhythm by using an additional needle. He proposed the following strategy:

• First move the topmost discs (say the top k discs) to one of the spare needles.
• Then use the standard three needles strategy to move the remaining n − k discs
(for a general case with n discs) to their destination.
• Finally, move the top k discs into their final destination using the four needles.

He calculated the value of k which minimized the number of movements and found that 18,433 transfers would suffice. Thus they could spend just 5 hours, 7 minutes, and 13 seconds with this scheme versus over 500, 000 million years without the additional needle!

Try to follow the clever priest’s strategy and calculate the number of transfers using four needles, where the priest can move only one disc at a time and must place each disc on a needle such that there is no smaller disc below it.

Calculate the k that minimizes the number of transfers under this strategy.

Input

The input file contains several lines of input. Each line contains a single integer 0 ≤ N ≤ 10, 000 giving the number of disks to be transferred. Input is terminated by end of file.

Output

For each line of input produce one line of output which indicates the number of movements required to transfer the N disks to the final needle.

Sample Input Sample Output
1 1
2 3
28 769
64 18433
__________________
C++/Java programmer
VOUCHES: 5
Reply With Quote
  #2  
Old 09-17-2011, 08:49 PM
spots13's Avatar
Active Member
$5 USD Donor New
 
Join Date: Feb 2008
Location: Colombia
Posts: 213
Send a message via MSN to spots13
Default Re: BotInc C++ Challenges

nice challenge
did it a while ago as a recursive challenge a teacher gave me
well going to leave some people try to do it legit before posting the source code
anyway good one hope you post the second one soon.

good luck

Last edited by spots13 : 09-17-2011 at 08:50 PM.
Reply With Quote
  #3  
Old 09-18-2011, 05:24 PM
Guru
 
Join Date: Jul 2005
Posts: 1,355
Send a message via MSN to wackywamba
Default Re: BotInc C++ Challenges

Ah what a classic question (:
__________________
Reply With Quote
Reply



Cheap RS Gold Store  Runescape Gold

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT +1. The time now is 07:05 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.1