UNPKG

maths.ts

Version:

Math utilities library for TypeScript, JavaScript and Node.js

22 lines (21 loc) 845 B
/** * Permutes an array arr.length! times or perms times. * @param arr The array to permute. * @param perms The maximum number of times to permute. * @returns An array with perms permutations of arr. */ export declare function permute<T>(arr: T[], perms: number): T[][]; /** * Permutes an array arr.length! times or perms times. This algorithm tries * to permute the array given randomly in order to get more diversity on NP * problem solutions. * @param arr The array to permute. * @param perms The maximum number of times to permute. * @returns An array with perms permutations of arr. */ export declare function randPermute<T>(arr: T[], perms?: number): T[][]; /** * Generates a random permutation with numbers from 0 to n - 1. * @param n The size of the array. */ export declare function randPermutation(n: number): number[];