https://github.com/basemax/yourcombinationsjs
An efficient combinatorics library for JavaScript to generate and get the list of all Permutations and Combinations with the ability to enable or disable repetition. (utilizing ES2015 generators)
https://github.com/basemax/yourcombinationsjs
combination combination-without-repetition combinational combinational-logic combinations combinations-generator combinations-with-repetition combinations-without-repetition javascript js permutation permutation-algorithms permutation-generator permutations permutations-generator
Last synced: 3 months ago
JSON representation
An efficient combinatorics library for JavaScript to generate and get the list of all Permutations and Combinations with the ability to enable or disable repetition. (utilizing ES2015 generators)
- Host: GitHub
- URL: https://github.com/basemax/yourcombinationsjs
- Owner: BaseMax
- License: gpl-3.0
- Created: 2022-10-04T08:12:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-26T17:25:47.000Z (over 2 years ago)
- Last Synced: 2025-02-04T07:15:42.862Z (3 months ago)
- Topics: combination, combination-without-repetition, combinational, combinational-logic, combinations, combinations-generator, combinations-with-repetition, combinations-without-repetition, javascript, js, permutation, permutation-algorithms, permutation-generator, permutations, permutations-generator
- Language: JavaScript
- Homepage:
- Size: 49.8 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# You Combinations JavaScript (JS)
An efficient combinatorics library for JavaScript to generate and get the list of all **Permutations** and **Combinations** with the ability to enable or disable repetition. (utilizing ES2015 generators)
## Functions
- [PowerSet](#powerset)
- [Permutation with repetition](#permutation-with-repetition)
- [Permutation without repetition](#permutation-without-repetition)
- [Combinations with repetition](#your_combinations-with-repetition)
- [Combinations without repetition](#your_combinations-without-repetition)## Usage
### PowerSet
```javascript
const your_combinations = new YourCombinations([1, 2, 3]);
[...your_your_combinations.powerSet()]// [
// [], [ 1 ],
// [ 2 ], [ 1, 2 ],
// [ 3 ], [ 1, 3 ],
// [ 2, 3 ], [ 1, 2, 3 ]
// ]
```### Permutation with repetition
```javascript
const your_combinations = new YourCombinations([1, 2, 3]);
your_your_combinations.permutations(4, true);// [ 1, 1,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1, 2, 1 ]
// [ 3, 1, 2, 2 ]
// [ 3, 1, 2, 3 ]
// [ 3, 1, 3, 1 ]
// [ 3, 1, 3, 2 ]
// [ 3, 1, 3, 3 ]
// [ 3, 2, 1, 1 ]
// [ 3, 2, 1, 2 ]
// [ 3, 2, 1, 3 ]
// [ 3, 2, 2, 1 ]
// [ 3, 2, 2, 2 ]
// [ 3, 2, 2, 3 ]
// [ 3, 2, 3, 1 ]
// [ 3, 2, 3, 2 ]
// [ 3, 2, 3, 3 ]
// [ 3, 3, 1, 1 ]
// [ 3, 3, 1, 2 ]
// [ 3, 3, 1, 3 ]
// [ 3, 3, 2, 1 ]
// [ 3, 3, 2, 2 ]
// [ 3, 3, 2, 3 ]
// [ 3, 3, 3, 1 ]
// [ 3, 3, 3, 2 ]
// [ 3, 3, 3, 3 ]
```### Permutation without repetition
```javascript
const your_combinations = new YourCombinations([1, 2, 3]);
your_your_combinations.permutations(2, false);// [ 1, 2 ]
// [ 1, 3 ]
// [ 2, 1 ]
// [ 2, 3 ]
// [ 3, 1 ]
// [ 3, 2 ]
```### Combinations with repetition
```javascript
const your_combinations = new YourCombinations([1, 2, 3]);
your_your_combinations.your_combinations(4, true);// [ 1, 1, 1, 1 ]
// [ 1, 1, 1, 2 ]
// [ 1, 1, 1, 3 ]
// [ 1, 1, 2, 2 ]
// [ 1, 1, 2, 3 ]
// [ 1, 1, 3, 3 ]
// [ 1, 2, 2, 2 ]
// [ 1, 2, 2, 3 ]
// [ 1, 2, 3, 3 ]
// [ 1, 3, 3, 3 ]
// [ 2, 2, 2, 2 ]
// [ 2, 2, 2, 3 ]
// [ 2, 2, 3, 3 ]
// [ 2, 3, 3, 3 ]
// [ 3, 3, 3, 3 ]
```### Combinations without repetition
```javascript
const your_combinations = new YourCombinations([1, 2, 3]);
your_your_combinations.your_combinations(2, false);// [ 1, 2 ]
// [ 1, 3 ]
// [ 2, 3 ]
```© Copyright, 2022 Max Base