An interesting programming challenge

Ben Rubinstein benr_mc at cogapp.com
Fri Apr 10 10:36:36 EDT 2015


On 10/04/2015 13:47, dunbarx wrote:
> My kluge took the same tack, that is to break the list into two parts, and
> play one against the other.
>
> This came about weeks ago because the routine I used to find all
> combinations of the 26 list items ran into a memory limit within LC that was
> less than the stated value of about 4GB (about 1GB, bug #15041).

I think the thing is that you can do recursion either depth-first or 
breadth-first.  Because we don't need to build up all the combinations (or 
even all the sums), but just test them as we go; and because some combinations 
never need to be explored (because they go over the desired sum before all the 
numbers have been added); if you do it depth-first, it doesn't use very much 
memory at all.

Ben




More information about the use-livecode mailing list