mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
rotate the last entries of the array first
e.g. for an input of ("abc", 2) aa, ab, ac, ba, bb, bc, ca, cb, cc This groups the permutations by common prefixes.
This commit is contained in:
parent
8695552fe6
commit
444f11161a
1 changed files with 1 additions and 1 deletions
|
@ -87,7 +87,7 @@ export function* permutationsWithReplacement(arr, n) {
|
|||
for (let _ of range(Math.pow(len, n))) {
|
||||
yield counters.map(i=>arr[i])
|
||||
for (let i of range(counters.length)) {
|
||||
if (index.mod(Math.pow(len, i)) === 0)
|
||||
if (index.mod(Math.pow(len, counters.length - 1 - i)) === 0)
|
||||
counters[i] = (counters[i] + 1).mod(len)
|
||||
}
|
||||
index++
|
||||
|
|
Loading…
Add table
Reference in a new issue