https://github.com/kevinsimard/combinatorics
PHP package for mathematical algorithms
https://github.com/kevinsimard/combinatorics
algorithms combinatorics php
Last synced: 6 months ago
JSON representation
PHP package for mathematical algorithms
- Host: GitHub
- URL: https://github.com/kevinsimard/combinatorics
- Owner: kevinsimard
- License: mit
- Created: 2016-02-18T20:00:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-01-03T16:20:10.000Z (over 8 years ago)
- Last Synced: 2026-01-14T13:54:08.388Z (6 months ago)
- Topics: algorithms, combinatorics, php
- Language: PHP
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Combinatorics
[](https://travis-ci.org/kevinsimard/combinatorics)
## Usage
You may add new elements to the list by using the `add` method:
```php
$instance = new Combinatorics(["foo", "bar"]);
$instance->add("baz");
$instance->add("qux");
// ["foo", "bar", "baz", "qux"]
```
You may also want to reset the list of elements by calling the `reset` method:
```php
$instance = new Combinatorics(["foo", "bar"]);
$instance->reset();
// []
```
### Permutations
```php
$elements = ["foo", "bar", "baz"];
$instance = new Combinatorics($elements);
foreach ($instance->permutations() as $value) {
...
}
// OR
foreach (Combinatorics::permutations($elements) as $value) {
...
}
// [
// ["foo", "bar", "baz"],
// ["bar", "foo", "baz"],
// ["bar", "baz", "foo"],
// ["foo", "baz", "bar"],
// ["baz", "foo", "bar"],
// ["baz", "bar", "foo"]
// ]
```
## Structure
├── src
│ └── Combinatorics.php
├── tests
│ └── CombinatoricsTest.php
├── .editorconfig
├── .gitattributes
├── .gitignore
├── .travis.yml
├── LICENSE.md
├── README.md
├── composer.json
├── composer.lock
└── phpunit.xml
## License
This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).