List Commands Library for 50g

07142017, 07:22 PM
Post: #41




RE: List Commands Library for 50g
I went ahead and implemented the I→NL command. It seemed silly not to, especially since it could be made to be a good performer via the use of a custom Saturn routine to populate the result list.
DOCOMB and DOPERM now have a local variable available for obtaining the "discards" from the source list after a combination has been selected. I'm not sure if there's a formal name for those elements, but I've been thinking of them as the "combination remnant", so the local is currently named CRMNT. Better naming suggestions are welcome! The user program can simply include CRMNT in its code at any point where those elements are needed. They are returned as a list. In searching for a good example problem to show the use of CRMNT with DOPERM, I decided that the "Vietnamese Snake Puzzle" from Gerald's post was a good match. It may also be easier to understand for the folks that already participated in that thread. If you're not familiar with it, I'd advise taking a look at the original source first to get an idea what it's about. Like many permutation problems, there is great benefit in recognizing the constraints that are built into the problem itself that may keep you from having to use a "bruteforce" approach that simply checks every possible permutation. For this example, I'm focusing on one of those constraints: ((13BI)+(CGH))/CI must be an integer in all of the final solutions. With that in mind, I've constructed the following program using commands from the library where appropriate. It essentially permutes the list of 9 digits, choosing 5 at a time for the initial test. For each of those permutations, it checks the above expression to see if it is an integer, and if so, continues to check the remaining digits as a potential solution to the final expression: Code: \<< I've commented this code copiously in an effort to make it clear what it does. On my 50g, it finds all 136 solutions in about 23.5 minutes. Further constraint checking would likely speed this up a bit, but I wanted to keep this as simple as possible while still showing a meaningful use of the CRMNT local. These latest changes (and a couple others) will be in the next update, which will hopefully be one of the last ones before finalizing the command set. I'll give it a couple more days as I continue to hammer out some more tests with it. 

« Next Oldest  Next Newest »

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