Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit59c6f4d

Browse files
committed
Optimize permutations algorithm.
1 parentd9946c1 commit59c6f4d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎src/algorithms/sets/permutations/permutateWithRepetitions.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ export default function permutateWithRepetitions(
1414
// Init permutations array.
1515
constpermutations=[];
1616

17+
// Get smaller permutations.
18+
constsmallerPermutations=permutateWithRepetitions(
19+
permutationOptions,
20+
permutationLength-1,
21+
);
22+
1723
// Go through all options and join it to the smaller permutations.
1824
permutationOptions.forEach((currentOption)=>{
19-
constsmallerPermutations=permutateWithRepetitions(
20-
permutationOptions,
21-
permutationLength-1,
22-
);
23-
2425
smallerPermutations.forEach((smallerPermutation)=>{
2526
permutations.push([currentOption].concat(smallerPermutation));
2627
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp