0

I'm in trouble with matrix combination algorithm. I need a function for getting combination of a matrix in javascript.

Sample input:

[
  ['a1', 'a2', 'a3'],
  ['b1'],
  ['c1', 'c2', 'c3']
]

Sample output:

[
  ['a1', 'b1', 'c1'],
  ['a1', 'b1', 'c2'],
  ['a1', 'b1', 'c3'],
  ['a2', 'b1', 'c1'],
  ['a2', 'b1', 'c2'],
  ['a2', 'b1', 'c3'],
  ['a3', 'b1', 'c1'],
  ['a3', 'b1', 'c2'],
  ['a3', 'b1', 'c3'],
]

What is the solution of this problem? Thanks.

Zoltan Veres
  • 357
  • 5
  • 27
Murat Ersin
  • 378
  • 5
  • 11

0 Answers0