(07-10-2022 10:37 PM)Didier Lachieze Wrote: Here is a solution to #1 on the Texas SR-52, the first programmable calculator with indirect register addressing back in 1975. It includes the list input.
Usage: 0 STO 99 then input each list element followed by [ A ], when finished input number N and press [ B ], after some time the program will return the index of the first element, press [RUN] to get the second element. You can then input another value for N and press [ B ] without having to input the list again. If there is no solution it returns 0 and 1.
Example: 0 [STO] 99 2 [A] 7 [A] 11 [A] 15 [A] 17 [ B ] returns 1 and 4 then 18 [ B] returns 2 and 3
Performance: On my SR-52 with upgraded memory it can handle lists up to 49 elements (vs. 19 on a regular SR-52).
With the list {1,2,3...48,49} searching for 3 returns 1 and 2 in 14 minutes. This is the worst case as the loops with dsz are done starting from the last element and going down.
Code:
Texas SR-52: 73 steps
Note: it uses the same notation as in the SR-52 manual:
* for the 2nd key and ' for the numeric labels (1', 2', 3')
//List input
000 46 11 *LBL A
002 65 x
003 01 44 09 09 1 SUM 99
007 95 =
008 36 42 09 09 *IND STO 99
012 56 *rtn
//Search
013 46 12 *LBL B
015 42 06 08 STO 68
018 43 09 09 RCL 99
021 42 00 00 STO 00
024 46 87 *LBL *1’
026 43 00 00 RCL 00
029 42 06 09 STO 69
032 58 88 *dsz *2’
034 41 89 GTO *3’
036 46 88 *LBL *2’
038 43 06 08 RCL 68
041 75 -
042 36 43 06 09 *IND RCL 69
046 75 -
047 36 43 00 00 *IND RCL 00
051 95 =
052 90 89 *if zro *3’
054 58 88 *dsz *2’
056 43 06 09 RCL 69
059 42 00 00 STO 00
062 58 87 *dsz *1’
064 46 89 *LBL *3’
066 43 00 00 RCL 00
069 81 HLT
070 43 06 09 RCL 69
073 56 *rtn
Nice.
By the way, I have never heard of an SR-52 with upgraded memory and I don't find any info online. Is this calculator one-of-a-kind? And does it also add more steps or only more registers?