1.0.4 • Published 10 months ago
@algorithm.ts/permutation v1.0.4
Create all permutations of the given natural number.
Install
npm
npm install --save @algorithm.ts/permutation
yarn
yarn 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] // ]