Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

## #26 2007-07-16 08:56:44

mikau
Super Member

Offline

### Re: The Tower of Hanoi

Oh oh I get it. Yeah, we can distribute the disks to more posts.

A logarithm is just a misspelled algorithm.

## #27 2007-07-16 09:01:27

Ricky
Moderator

Offline

### Re: The Tower of Hanoi

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..."

## #28 2007-07-21 03:11:20

Mathskido
Member

Offline

### Re: The Tower of Hanoi

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]http://images.ugoto.com/icons/archive/animals/cat.gif[/img]
[img]C:\Documents and Settings\Alex\Desktop\Stuff\Pictures[/img]

## #29 2007-07-22 15:39:41

mikau
Super Member

Offline

### Re: The Tower of Hanoi

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.

## #30 2007-07-22 16:19:17

Ricky
Moderator

Offline

### Re: The Tower of Hanoi

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..."

## #31 2007-07-23 01:35:11

mikau
Super Member

Offline

### Re: The Tower of Hanoi

do we have access to that?

A logarithm is just a misspelled algorithm.

## #32 2007-07-23 03:05:39

Ricky
Moderator

Offline

### Re: The Tower of Hanoi

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..."

## Board footer

Powered by FluxBB