Merge branch 'master' into patch-1

This commit is contained in:
Mateus Oliveira 2018-12-14 14:45:02 -02:00 committed by GitHub
commit 5b24306e4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,13 +14,14 @@ export default function permutateWithRepetitions(
// Init permutations array.
const permutations = [];
// Get smaller permutations.
const smallerPermutations = permutateWithRepetitions(
permutationOptions,
permutationLength - 1,
);
// Go through all options and join it to the smaller permutations.
permutationOptions.forEach((currentOption) => {
const smallerPermutations = permutateWithRepetitions(
permutationOptions,
permutationLength - 1,
);
smallerPermutations.forEach((smallerPermutation) => {
permutations.push([currentOption].concat(smallerPermutation));
});