Horje
how to find all permutations of an array with javascript Code Example
how to find all permutations of an array with javascript
function getArrayMutations(arr, perms = [], len = arr.length) {
  if (len === 1) perms.push(arr.slice(0))

  for (let i = 0; i < len; i++) {
    getArrayMutations(arr, perms, len - 1)

    len % 2 // parity dependent adjacent elements swap
      ? [arr[0], arr[len - 1]] = [arr[len - 1], arr[0]]
      : [arr[i], arr[len - 1]] = [arr[len - 1], arr[i]]
  }

  return perms
}




Javascript

Related
jquery id click Code Example jquery id click Code Example
how to get datetime in nodejs Code Example how to get datetime in nodejs Code Example
how to stop iframe video using javascript Code Example how to stop iframe video using javascript Code Example
html video  time Code Example html video time Code Example
moment get week day Code Example moment get week day Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10