How do I learn RPL and solve this problem with it?
09-25-2017, 05:48 AM (This post was last modified: 09-25-2017 05:50 AM by pier4r.)
Post: #14
 pier4r Senior Member Posts: 2,128 Joined: Nov 2014
RE: How do I learn RPL and solve this problem with it?
My second approach, inspired by the discussion with hp67 (thanks!) is to pre-compute the value and then having the real program searching the right value among the pre-computed ones .

So at the moment I am in the process to pre compute the value (not storing them on the SD card at first) but on the 50g it takes quite a while.

Since I discovered that the 50g when it is busy does not update the clock, I can tell how long it is computing.

In this moment the actual date is: 2017-09-25-07-46
The calculator shows the clock locked at 2017-09-24-22-18

I checked the program once again and I do not see parts where it can end in loop, so I leave it running because it can end from a moment to another.

Surely I feel that there would be room for improvement.

Code:
 \<<     { 10 12 15 18 22 27 33 39 47 56 68 82 }  "baseResistors" DROP     { 1. 1.2 1.5 1.8 2.2 2.7 3.3 3.9 4.7 5.6 6.8 8.2  10. 12. 15. 18. 22. 27. 33. 39. 47. 56. 68. 82. 100. 120.  150. 180. 220. 270. 330. 390. 470. 560. 680.  820. 1000. 1200. 1500. 1800. 2200. 2700. 3300.  3900. 4700. 5600. 6800. 8200. 10000. 12000.  15000. 18000. 22000. 27000. 33000. 39000.  47000. 56000. 68000. 82000. 100000. 120000.  150000. 180000. 220000. 270000. 330000. 390000.  470000. 560000. 680000. 820000. 1000000. 1200000.  1500000. 1800000. 2200000. 2700000. 3300000.  3900000. 4700000. 5600000. 6800000. 8200000.  10000000. 12000000. 15000000. 18000000.  22000000. 27000000. 33000000. 39000000. 47000000.  56000000. 68000000. 82000000. } "allResistors" DROP     DUP SIZE "allResistorsNumber" DROP     { 0.1 10 100 1000 10000 100000 1000000 } "resistorRanges" DROP     {} "resultSerial" DROP     {} "resultParallel" DROP     0 "value1" DROP     0 "value2" DROP     {} "allResistorsListTemp" DROP     {} "allResistorsListTemp2" DROP          \->     @input          @localVar     baseResistors     allResistors     allResistorsNumber     resistorRanges     resultSerial     resultParallel     value1     value2     allResistorsListTemp     allResistorsListTemp2          \<<       \<<         @first we build the list of all possible resistors from the base one.              @for every element in the range of resistors we expand the list of available         @resistors         1 resistorRanges SIZE         FOR position           'allResistors'           baseResistors           resistorRanges position GET           *           STO+         NEXT                  @now we order the resistors, although it is not strictly needed for the result         allResistors :2:LSORT EVAL 'allResistors' STO               @we can also save the result as precomputed list       \>>        DROP         @not needed, we have the list precomputed now.            @here we have all the resistors needed.       @now we need to compute all the possible compositions of those in serial or parallel.              @computing the result in order, so from the position of the element we can       @infer the two components making the element (maybe not that easy with more than)       @two components.       @Cannot use docomb for this due to the not predictable way of making combinations.              allResistors 'allResistorsListTemp' STO              1 allResistorsNumber 1 -       FOR index1         allResistorsListTemp LPOP         'value1' STO         'allResistorsListTemp' STO                  allResistorsListTemp 'allResistorsListTemp2' STO                  index1 1 + allResistorsNumber         START           allResistorsListTemp2 LPOP           'value2' STO           'allResistorsListTemp2' STO                      'resultSerial'           value1 value2 +           STO+         NEXT       NEXT              resultSerial     \>>   \>>

Once again, setq, if you have question about the syntax of the program (I have no doubts that you can figure out the meaning once being able to decode the syntax), ask!

edit: discovered that the code block on thi forum limits the shown text vertically but not horizontally. It was not expected.

Wikis are great, Contribute :)
 « Next Oldest | Next Newest »

 Messages In This Thread How do I learn RPL and solve this problem with it? - setq - 09-24-2017, 12:48 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-24-2017, 01:29 PM RE: How do I learn RPL and solve this problem with it? - HP67 - 09-24-2017, 01:44 PM RE: How do I learn RPL and solve this problem with it? - John Keith - 09-24-2017, 03:03 PM RE: How do I learn RPL and solve this problem with it? - setq - 09-24-2017, 03:18 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-24-2017, 03:21 PM RE: How do I learn RPL and solve this problem with it? - HP67 - 09-24-2017, 04:06 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-24-2017, 04:10 PM RE: How do I learn RPL and solve this problem with it? - HP67 - 09-24-2017, 04:14 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-24-2017, 04:17 PM RE: How do I learn RPL and solve this problem with it? - HP67 - 09-24-2017, 04:25 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-24-2017, 06:02 PM RE: How do I learn RPL and solve this problem with it? - Brad Barton - 09-24-2017, 06:35 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-25-2017 05:48 AM RE: How do I learn RPL and solve this problem with it? - HP67 - 09-25-2017, 04:08 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-25-2017, 05:39 PM RE: How do I learn RPL and solve this problem with it? - mfleming - 09-25-2017, 06:36 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-25-2017, 08:27 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-26-2017, 06:03 AM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-26-2017, 02:50 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-26-2017, 02:55 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-26-2017, 06:37 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-26-2017, 06:57 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-26-2017, 08:22 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-25-2017, 07:10 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-25-2017, 07:41 PM RE: How do I learn RPL and solve this problem with it? - David Hayden - 09-25-2017, 07:55 PM RE: How do I learn RPL and solve this problem with it? - emece67 - 09-25-2017, 08:04 PM RE: How do I learn RPL and solve this problem with it? - Gerson W. Barbosa - 09-26-2017, 04:37 PM RE: How do I learn RPL and solve this problem with it? - Dieter - 09-26-2017, 07:01 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-26-2017, 08:25 PM RE: How do I learn RPL and solve this problem with it? - Dieter - 09-26-2017, 08:36 PM RE: How do I learn RPL and solve this problem with it? - David Hayden - 09-25-2017, 08:17 PM RE: How do I learn RPL and solve this problem with it? - brickviking - 09-26-2017, 01:02 AM RE: How do I learn RPL and solve this problem with it? - John Keith - 09-26-2017, 12:06 PM RE: How do I learn RPL and solve this problem with it? - Claudio L. - 09-26-2017, 02:29 PM RE: How do I learn RPL and solve this problem with it? - David Hayden - 09-26-2017, 01:02 PM RE: How do I learn RPL and solve this problem with it? - Dieter - 09-26-2017, 06:20 PM RE: How do I learn RPL and solve this problem with it? - Didier Lachieze - 09-26-2017, 06:46 PM RE: How do I learn RPL and solve this problem with it? - pier4r - 09-26-2017, 10:20 PM

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