Utility for listing and counting combinations and permutations.
$ npm i percom
import percom from "percom";
percom.com(array, r);
// array: source array
// r: size of each combinationExample
const array = ["A", "B", "C"];
const result1 = percom.com(array, 2);
// result1 = [["A", "B"], ["A", "C"], ["B", "C"]]
const result2 = percom.com(array, 1);
// result2 = [["A"], ["B"], ["C"]]percom.countCom(n, r);
// n: number of elements
// r: size of each combinationExample
percom.countCom(8, 3); // => 56percom.per(array, r);
// array: source array
// r: size of each permutationExample
const array = ["A", "B", "C"];
const result1 = percom.per(array, 2);
// result1 = [["A", "B"], ["A", "C"], ["B", "A"], ["B", "C"], ["C", "A"], ["C", "B"]]
const result2 = percom.per(array, 1);
// result2 = [["A"], ["B"], ["C"]]percom.countPer(n, r);
// n: number of elements
// r: size of each permutationExample
percom.countPer(8, 3); // => 336percom is available under the MIT License.
yarn install
// before creating a PR
yarn mochaSince lint-staged and husky are set up, your code will be formatted before commit.
Kota Yatagai (https://kota_yata.com)
