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

You are not logged in.

- Topics: Active | Unanswered

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

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

A logarithm is just a misspelled algorithm.

Offline

**Ricky****Moderator**- Registered: 2005-12-04
- Posts: 3,791

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

**Mathskido****Member**- Registered: 2007-07-20
- Posts: 18

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]

Offline

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

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

**Ricky****Moderator**- Registered: 2005-12-04
- Posts: 3,791

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

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

do we have access to that?

A logarithm is just a misspelled algorithm.

Offline

**Ricky****Moderator**- Registered: 2005-12-04
- Posts: 3,791

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