dankogai / js-combinatorics

power set, combination, permutation and more in JavaScript
MIT License
742 stars 97 forks source link

Permutation with Repetition #9

Closed alexbeletsky closed 10 years ago

alexbeletsky commented 10 years ago

Sorry, I don't know exact English term for this, but that should be know as Permutation with Repetition, total number of permutations is n ^ r.

I have an alphabet, 'a, b, c, d, e' and need to generate all possible permutations, including ones

[a, a, a, a],
[a, b, a, a]
[a, b, c, a]

etc.

Can it be done with js-combinatorics?

dankogai commented 10 years ago

It is more like a number represented as an array which digits are elements in the argument.

I added .baseN which is exactly what you are looking for in version 0.4.0.

alexbeletsky commented 10 years ago

Great addition, thank you!