Puzzle - RPL and others
04-25-2021, 09:25 AM (This post was last modified: 04-25-2021 04:57 PM by C.Ret.)
Post: #12
 C.Ret Member Posts: 266 Joined: Dec 2013
RE: Puzzle - RPL and others
Coding this puzzle on RPL's and powerful BASIC's pocket systems that natively support recurrence was an easy task !

A much more challenging is to adapt this algorithm on a pocket that have no support at all for recurrencies nor any serious structure for array !

Here is the same algorithm for SHARP PC-1211 (or other Tandy and SHARP equivalent), all you need is 129 steps and following variables:

A to I: (respectively A(1) to A(9) ) for memorizing scanned values of increasing number of digits,
J to R: (respectively A(10) to A(18) ) for noting at which level & position a digit is already used at,
U & V: Pointers indicating the actual size of the scan value and at which digit is currently probe.
T : Actual value to be probe, result at end of the whole seeking process,
Z : Use for division testing of the scan figure.

1:CLEAR :FOR U=1TO 9:A(U)=T:FOR V=1TO 9
2:IF A(9+V)=0LET T=10A(U)+V,Z=T/U:IF Z=INT ZLET A(9+V)=U,V=99 :REM PAUSE A(U),T
3:IF V=9LET U=U-1,V=A(U+1)-10A(U),A(9+V)=0:GOTO 3
4:NEXT V:NEXT U:BEEP 1:PRINT T:END
129STEPS
MEM
1295STEPS 161MEMORIES

As for previous code post here, the trick is to memorize only correct partial figure in the stack (since there is no way here to use recurrence) A to I in the same time, the J to R stack memorize used digit and record at which position in the value which also correspond to the level of seek.
A zero value in the J-R stack indicate a free digit.

Note the affectation V=99 which is equivalent for an BREAK (or LEAVE) instruction missing on these venerable old fashion canonic BASIC.

Without any intermediate message (the PAUSE at end of line 2: was heavily used for debugging the process), the solution is found in about 16'24"

here the complet trace of the seek up to the solution:
Code:
Seek levels:                                               Target A: B:  C:   D:    E:     F:      G:       H:        I:     T:  0. 1. 12. 123. 1236. 12365. 123654.       12. 126. 1264. 12645.                1268. 12685.           129. 1296. 12965. 129654. 1296547.                1298. 12984.        14. 147. 1472. 14725. 147258. 1472583.                1476. 14765.       16. 162. 1624. 16245.                1628. 16285.           165. 1652.           168. 1684. 16845.       18. 183. 1832. 18325.                1836. 18365. 183654.           186. 1864. 18645.           189. 1892. 18925.                1896. 18965. 189654.    2. 24. 243. 2436. 24365.           246. 2468. 24685.           249. 2496. 24965.        26. 261.            264. 2648. 26485.           267.       28. 285. 2856.    3. 32. 321. 3216. 32165. 321654. 3216549.           324. 3248. 32485.           327. 3276. 32765. 327654.       34. 342. 3428. 32485.            345. 3452.                3456.           348.       36. 369. 3692. 36925. 369258. 3692584.       38. 381. 3812. 38125.                3816. 38165. 381654. 3816547.38164572.       381654729.

[attachment=9414]
 « Next Oldest | Next Newest »

 Messages In This Thread Puzzle - RPL and others - Gene - 04-22-2021, 06:55 PM RE: Puzzle - RPL and others - Valentin Albillo - 04-22-2021, 11:52 PM RE: Puzzle - RPL and others - rprosperi - 04-23-2021, 04:21 PM RE: Puzzle - RPL and others - EdS2 - 04-23-2021, 07:30 AM RE: Puzzle - RPL and others - Dave Britten - 04-23-2021, 12:06 PM RE: Puzzle - RPL and others - 3298 - 04-23-2021, 09:17 AM RE: Puzzle - RPL and others - ijabbott - 04-23-2021, 03:57 PM RE: Puzzle - RPL and others - Albert Chan - 04-23-2021, 04:08 PM RE: Puzzle - RPL and others - Albert Chan - 04-27-2021, 12:14 PM RE: Puzzle - RPL and others - Didier Lachieze - 04-23-2021, 04:23 PM RE: Puzzle - RPL and others - 3298 - 04-23-2021, 09:05 PM RE: Puzzle - RPL and others - C.Ret - 04-24-2021, 04:40 PM RE: Puzzle - RPL and others - C.Ret - 04-25-2021 09:25 AM RE: Puzzle - RPL and others - Claudio L. - 04-26-2021, 04:56 PM RE: Puzzle - RPL and others - 3298 - 04-27-2021, 08:16 PM RE: Puzzle - RPL and others - Albert Chan - 04-28-2021, 02:33 AM RE: Puzzle - RPL and others - Albert Chan - 04-28-2021, 03:30 AM RE: Puzzle - RPL and others - 3298 - 04-28-2021, 10:14 PM RE: Puzzle - RPL and others - Albert Chan - 04-29-2021, 03:25 AM RE: Puzzle - RPL and others - Allen - 04-28-2021, 08:45 PM RE: Puzzle - RPL and others - Albert Chan - 04-29-2021, 05:16 PM RE: Puzzle - RPL and others - Allen - 04-29-2021, 07:03 PM RE: Puzzle - RPL and others - C.Ret - 05-02-2021, 06:40 AM RE: Puzzle - RPL and others - 3298 - 05-03-2021, 03:43 PM RE: Puzzle - RPL and others - Albert Chan - 05-04-2021, 03:29 AM RE: Puzzle - RPL and others - 3298 - 05-04-2021, 06:48 AM RE: Puzzle - RPL and others - Albert Chan - 05-05-2021, 06:29 PM RE: Puzzle - RPL and others - 3298 - 05-06-2021, 04:24 PM RE: Puzzle - RPL and others - Albert Chan - 05-06-2021, 09:09 PM RE: Puzzle - RPL and others - Albert Chan - 05-07-2021, 10:35 AM RE: Puzzle - RPL and others - 3298 - 05-07-2021, 04:17 PM RE: Puzzle - RPL and others - Albert Chan - 05-09-2021, 01:21 AM RE: Puzzle - RPL and others - 3298 - 05-09-2021, 01:39 PM RE: Puzzle - RPL and others - Albert Chan - 05-10-2021, 03:57 AM RE: Puzzle - RPL and others - Albert Chan - 05-07-2021, 02:56 AM RE: Puzzle - RPL and others - Albert Chan - 05-10-2021, 05:13 PM RE: Puzzle - RPL and others - 3298 - 05-10-2021, 08:23 PM RE: Puzzle - RPL and others - Albert Chan - 05-11-2021, 11:58 AM RE: Puzzle - RPL and others - 3298 - 05-11-2021, 02:14 PM RE: Puzzle - RPL and others - John Keith - 05-11-2021, 03:55 PM RE: Puzzle - RPL and others - ijabbott - 05-11-2021, 10:37 PM RE: Puzzle - RPL and others - Albert Chan - 05-13-2021, 11:38 PM

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