You are not logged in.
Oh oh I get it. Yeah, we can distribute the disks to more posts.
A logarithm is just a misspelled algorithm.
Offline
Since Luca already answered it partially, here is a faster solution for n pegs:
Move (k-1)/(n-2) to each of the n-2 pegs, leaving the first with only the bottom disk and the last peg empty. Note there may be additional ones left over because of integer division. This will cost f((k-1)/(n-2)), the same f as before. Now move the big disk over, and stack all the others on top, each costing f((k-1)/(n-2)). The total cost is:
2*(n-2)*f((k-1)/(n-2)) + 1
Is this the fastest way?
"In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..."
Offline
I've played it once, but I can't played it any more because it flashes a lot when I play it.
High score in SAT's at the end of Year 6, Virgo, D'oh!, www.freewebs.com/roadster96
[img]C:\Documents and Settings\Alex\Desktop\Stuff\Pictures[/img]
Offline
oh that applet?
actually thats an EXTREMELY irritating occurance that annoys the heck out of me with java applets. Whenever you tell the screen to refresh it flickers. If it refreshes everytime you move the mouse, its just.. a nightmare.
I'm not sure if it does that with jframes though..
A logarithm is just a misspelled algorithm.
Offline
actually thats an EXTREMELY irritating occurance that annoys the heck out of me with java applets. Whenever you tell the screen to refresh it flickers. If it refreshes everytime you move the mouse, its just.. a nightmare.
Double buffering will eliminate the flicker.
"In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..."
Offline
do we have access to that?
A logarithm is just a misspelled algorithm.
Offline
Yep. What you do is create an image, then set a graphics object to associate with that image:
Image backi;
Graphics backg;
backi = createImage(width, height);
backg = backi.getGraphics();
Now do all your drawing on backg, just as you would on the normal graphics object. When you want to swap images, simply call:
g.drawImage(backi, 0, 0, this);
Note that "g" here is the normal graphics object you get from some method like update(Graphics g).
"In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..."
Offline