Post Reply 
Programming puzzles: processing lists!
06-05-2017, 09:29 PM (This post was last modified: 06-24-2017 09:30 PM by Gilles59.)
Post: #128
RE: Programming puzzles: processing lists!
(06-05-2017 05:33 PM)DavidM Wrote:  DOPERM

I'll think about that. As I'm sure you're aware, the resources of the calculator imply that any command for permutation/combination iteration is likely to have significant limitations. While your given example is certainly feasible, the iterations increase rather quickly with even minimal increases in the numbers. And even if the computation speed can be minimized, processing large lists tends to create memory and garbage collection issues that also hamper overall use of the system. What is the scope of this type of command that you would find reasonable?

The idea is not, in general, to return a list with all the permutations of the list (this is only possible for small list permutations because of the limited RAM).

But see this puzzle, for example :

Quote:
13597 is a prime number. What are all the prime numbers with these 5 digits ?

Code:

<< 
 { 1 3 5 9 7 } 5 
 << 
   {10000 1000 100 10 1 } * ΣLIST 
   IF DUP ISPRIME? NOT THEN DROP END
 >>
 DOPERM
>>

This will return the list of all the prime numbers with all the 1 3 5 9 7 digits.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming puzzles: processing lists! - Gilles59 - 06-05-2017 09:29 PM



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