@algorithm.ts/permutation
v1.0.5
Published
Tranverse the permutation of a list.
Readme
Create all permutations of the given natural number.
Install
npm
npm install --save @algorithm.ts/permutationpnpm
pnpm add @algorithm.ts/permutation
Usage
Basic
import { permutation } from '@algorithm.ts/permutation' for (const nums of permutation(7)) { // Tranverse the permutation of [0, 1, 2, 3 ,4, 5, 6] } Array.from(permutation(3, 1)) // [ // [1, 2, 3], // [1, 3, 2], // [2, 1, 3], // [2, 3, 1], // [3, 1, 2], // [3, 2, 1] // ]
