Created
December 24, 2021 12:22
-
-
Save fronterior/32d4729b2a7a6efb1642ece8f182e3bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const args = [ | |
[1,2,3], | |
[1], | |
['a', 'b'], | |
['c', 'd', 'e'], | |
[5], | |
]; | |
const r = [[]] as any; | |
let i = 0; | |
while (i++ !== args.length) { | |
const s = []; | |
while (r.length) { | |
const t = r.shift(); | |
if (t.length < args.length) { | |
args[t.length].map(i => s.push([...t, i])); | |
} | |
} | |
r.push(...s); | |
} | |
console.log(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment