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
|
|||
|
|||
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 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): And this is the generated output: Code: (disk, from, to) 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 »
|
User(s) browsing this thread: 1 Guest(s)