list-extra icon indicating copy to clipboard operation
list-extra copied to clipboard

Permutation Memory Issues

Open Chadtech opened this issue 8 years ago • 3 comments

In the slack channel, Numiastowski discovered that permutations causes a memory problem. A list of 9 elements might have as many as 9! permutations, and therefore, 9! stack calls.

I believe this can be solved by implementing something like this: https://www.nayuki.io/page/next-lexicographical-permutation-algorithm, or ~~any non-recursive permutation function~~.

But before settling on that, we should consider use cases of the permutation function. Has anyone used it? How did you use it? What problem did it solve for you?

Chadtech avatar Jun 14 '17 19:06 Chadtech

Maybe it should be lazy?

pzp1997 avatar Jun 14 '17 20:06 pzp1997

@zwilias made this cool Ellie app demonstrating an implementation of the next permutation algorithm. Could be useful to this project : https://ellie-app.com/3vnrtbJffbYa1/0

Chadtech avatar Jun 19 '17 19:06 Chadtech

We might want to consider the implementation of subsequences as well, which outputs a list of 2n lists for an input list of length n.

pzp1997 avatar Jun 23 '17 20:06 pzp1997