dev-master
9999999-devGenerates combinations of a set.
MIT
The Requires
- php >=7.0
The Development Requires
by Kieran Patel
v0.1
0.1.0.0Generates combinations of a set.
MIT
The Requires
- php >=7.0
The Development Requires
by Kieran Patel
Wallogit.com
2017 © Pedro Peláez
Generates combinations of a set.
Generates combinations of a set, (*1)
A combination is a set of size k from a number of values > k that does not repeat., (*2)
For example, given the values Jim, Jane, Bob, Susan, Ralph, all the possible combinations of size 3 are as follows:, (*3)
Jim, Jane, Bob Jim, Jane, Susan Jim, Jane, Ralph Jim, Bob, Susan Jim, Bob, Ralph Jim, Susan, Ralph Jane, Bob, Susan Jane, Bob, Ralph Jane, Susan, Ralph Bob, Susan, Ralph
(credit to this awesome calculator for the example)., (*4)
composer require kieranajp/combinator, (*5)
The provided Combinator class is an instance of Iterator, so combinations can be collected by looping over it., (*6)
For example:, (*7)
use Kieranajp\Combinator\Combinator;
$size = 3;
$combinator = new Combinator([1, 2, 3, 4, 5], $size);
$items = [];
foreach ($c as $item) {
$items[] = $item;
}
The $items array will now contain all possible combinations of size $size., (*8)
Pull requests are welcome. Please adhere to PSR-2. I intend to add a Permutator to this package, as well., (*9)
MIT License, (*10)
Copyright (c) 2016 Kieran Patel, (*11)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*12)
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*13)
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*14)
Generates combinations of a set.
MIT
Generates combinations of a set.
MIT