Weakest calculator/pocket computer that can do Tower of Hanoi?
|
08-12-2018, 07:16 AM
(This post was last modified: 08-12-2018 01:19 PM by Thomas Klemm.)
Post: #7
|
|||
|
|||
RE: Weakest calculator/pocket computer that can do Tower of Hanoi?
This program for the HP-11C implements A001511:
Code: 01▸LBL A Quote:a(n) = number of disk to be moved at n-th step of optimal solution to Towers of Hanoi problem It uses the following method to calculate \(a(n)\): Quote:a(n) is the number of digits that must be counted from right to left to reach the first 1 in the binary representation of n. Example with 3 disks Hint: Move odd disks to the right and even disks to the left. 1 [A] → 1 ; move disk 1 to the right 2 [A] → 2 ; move disk 2 to the left 3 [A] → 1 ; move disk 1 to the right 4 [A] → 3 ; move disk 3 to the right 5 [A] → 1 ; (…) 6 [A] → 2 7 [A] → 1 (08-11-2018 08:35 PM)Thomas Okken Wrote: Doing it on the 25 does seem a bit ambitious. It should be possible to convert this program for the HP-25. Cheers Thomas Edit: Fixed typo in line 08 of the program. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)