dankogai/js-combinatorics

Combination with repetition

Closed this issue · 1 comments

combinations with repetition are currently not supported, right?
Something like that would be awesome!

Combinatorics.combinationWithRep(['a', 'b', 'c'], 4)
/*
=> [ 
  [ 'a', 'a', 'a', 'a' ],
  [ 'a', 'a', 'a', 'b' ],
  [ 'a', 'a', 'a', 'c' ],
  [ 'a', 'a', 'b', 'b' ],
  [ 'a', 'a', 'b', 'c' ],
  [ 'a', 'a', 'c', 'c' ],
  [ 'a', 'b', 'b', 'b' ],
  [ 'a', 'b', 'b', 'c' ],
  [ 'a', 'b', 'c', 'c' ],
  [ 'a', 'c', 'c', 'c' ],
  [ 'b', 'b', 'b', 'b' ],
  [ 'b', 'b', 'b', 'c' ],
  [ 'b', 'b', 'c', 'c' ],
  [ 'b', 'c', 'c', 'c' ],
  [ 'c', 'c', 'c', 'c' ] 
 ]
*/

baseN essentially does this, just not in the order you are indicating