Weakest calculator/pocket computer that can do Tower of Hanoi?
08-12-2018, 09:35 AM (This post was last modified: 08-12-2018 09:48 AM by Thomas Klemm.)
Post: #10
 Thomas Klemm Senior Member Posts: 1,768 Joined: Dec 2013
RE: Weakest calculator/pocket computer that can do Tower of Hanoi?
(08-12-2018 07:46 AM)Thomas Okken Wrote:  That program always returns 1, for any input.

That's weird. Are you sure that you've entered these lines?
Code:
13 1 14 +

Quote:Even if it did do what you say it should do, it would still be only a partial solution, because all it would tell you is which disc should be moved at any given step. The reason why my (second) program is so much longer is because it works out from from which to which position the disc is moved.

It depends on how a solution is specified. You could give the sequence A001511 to someone and without understanding the rules it would be possible to play the game. You'd have to know how to move odd and even disk numbers differently but you could colour the disks accordingly which would give them a nice touch.

If you desperately need to know the positions they could be calculated from $$n$$ and $$a(n)$$:

Here's a Python program:
Code:
def hanoi(n):     k, a = n, 1     while not k % 2:         k /= 2         a += 1     p = n / 2**a     q, r = (p % 3, (p+1) % 3) if a % 2 else ((-p) % 3, (-p-1) % 3)     return a, q, r for i in range(1, 2**5):     print hanoi(i)

And this is the generated output:
Code:
(disk, from, to) (1, 0, 1) (2, 0, 2) (1, 1, 2) (3, 0, 1) (1, 2, 0) (2, 2, 1) (1, 0, 1) (4, 0, 2) (1, 1, 2) (2, 1, 0) (1, 2, 0) (3, 1, 2) (1, 0, 1) (2, 0, 2) (1, 1, 2) (5, 0, 1) (1, 2, 0) (2, 2, 1) (1, 0, 1) (3, 2, 0) (1, 1, 2) (2, 1, 0) (1, 2, 0) (4, 2, 1) (1, 0, 1) (2, 0, 2) (1, 1, 2) (3, 0, 1) (1, 2, 0) (2, 2, 1) (1, 0, 1)

Is that what you want?

Not sure if we can squeeze that into the 49 lines of a HP-25 though.

(08-12-2018 01:46 AM)Thomas Okken Wrote:  Not having MOD really hurts.

Agreed.

Cheers
Thomas
 « Next Oldest | Next Newest »

 Messages In This Thread Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-11-2018, 05:26 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-11-2018, 06:42 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-11-2018, 06:52 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-11-2018, 08:35 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-12-2018, 01:46 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-12-2018, 01:52 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018, 07:16 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-12-2018, 07:46 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018, 08:10 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018 09:35 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-12-2018, 01:19 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018, 01:16 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018, 01:32 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018, 05:08 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-12-2018, 06:07 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Paul Dale - 08-13-2018, 01:38 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-13-2018, 03:40 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Paul Dale - 08-13-2018, 07:03 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - SlideRule - 08-13-2018, 12:45 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-13-2018, 11:47 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - SlideRule - 08-13-2018, 01:31 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-13-2018, 01:07 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-13-2018, 03:58 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-13-2018, 04:02 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-14-2018, 12:47 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Paul Dale - 08-14-2018, 04:18 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Jake Schwartz - 08-15-2018, 03:49 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-15-2018, 04:39 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Gene - 08-15-2018, 05:31 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-15-2018, 08:12 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - SlideRule - 08-29-2018, 11:32 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-30-2018, 03:36 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - SlideRule - 08-30-2018, 11:57 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - SlideRule - 10-29-2018, 02:15 PM

User(s) browsing this thread: 1 Guest(s)