bluss / permutohedron

https://docs.rs/permutohedron/
Apache License 2.0
38 stars 5 forks source link

Heap element limit? #6

Closed polarathene closed 7 years ago

polarathene commented 7 years ago

The docs for heap don't mention a max element limit. The docs for heap_recursive do refer that it does while heap_recursive does not(but small element sizes only being practical).


I'm new to Rust but what I can make of the two is, heap provides an iterator supporting up to 16 elements that will allow me to step through permutations calculating only as many as I request(eg first 100). heap_recursive doesn't offer this and will compute/return every single permutation on the spot with no way to pause and resume?

I was wanting to use your library for permutating a string length of a given charset(eg 26 characters/elements "a" to "z"). It doesn't sound like that is possible, or that it could handle this type of permutation? eg 26^3 "aaa" "aab" "aac" and so on until "zzz". The number example seems to convey your library only permutates n! where each element is unique, it could not take [1, 2, 3] and have a permutation of [1,1,3]?

bluss commented 7 years ago

heap_recursive has been extended and allows stopping midway in the most recent version.

bluss commented 7 years ago

It sounds to me like you want combinations with replacement, not permutations.

polarathene commented 7 years ago

I want in the example 26^3 unique permutations, 26 letters(possible numbers) with string lengths of 3(numbers used). This is permutations with repetition, 17576 permutations. Combinations and Permutations calculator, Combinations with replacement calculator.

Combinations: 2600 Combinations with replacement/repetition: 3276 Permutations: 15600 Permutations with repetition: 17576

I've worked on my own solution to this that works quite well, I might publish it as a crate in future. Your docs could still benefit clarifying the above differences and limits :)