combinationsReplacement
combinationsReplacement(
x,k):any[][]
Defined in: src/combinations_replacement.js:13
Implementation of Combinations with replacement Combinations are unique subsets of a collection - in this case, k x from a collection at a time. ‘With replacement’ means that a given element can be chosen multiple times. Unlike permutation, order doesn’t matter for combinations.
Parameters
Section titled “Parameters”any[]
any type of data
int
the number of objects in each group (with replacement)
Returns
Section titled “Returns”any[][]
array of combinations
Example
Section titled “Example”combinationsReplacement([1, 2], 2); // => [[1, 1], [1, 2], [2, 2]]