{"id":16568689,"url":"https://github.com/drupol/phpermutations","last_synced_at":"2025-04-05T23:09:24.177Z","repository":{"id":56972712,"uuid":"76895054","full_name":"drupol/phpermutations","owner":"drupol","description":"Generate Permutations and Combinations in an efficient way.","archived":false,"fork":false,"pushed_at":"2024-05-15T07:01:01.000Z","size":166,"stargazers_count":79,"open_issues_count":1,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-11T21:11:46.899Z","etag":null,"topics":["combinations","fibonacci","generator","mathematics","permutation","php-iterator","prime-numbers"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drupol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"drupol"}},"created_at":"2016-12-19T20:31:37.000Z","updated_at":"2024-07-23T17:47:45.000Z","dependencies_parsed_at":"2024-06-18T13:49:56.731Z","dependency_job_id":"341b4985-5c9e-4f55-94d2-2a20575f0eb7","html_url":"https://github.com/drupol/phpermutations","commit_stats":{"total_commits":47,"total_committers":3,"mean_commits":"15.666666666666666","dds":0.4893617021276596,"last_synced_commit":"869912ebee25a761f09518299004eefd1c73f280"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupol%2Fphpermutations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupol%2Fphpermutations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupol%2Fphpermutations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupol%2Fphpermutations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drupol","download_url":"https://codeload.github.com/drupol/phpermutations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411235,"owners_count":20934653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["combinations","fibonacci","generator","mathematics","permutation","php-iterator","prime-numbers"],"created_at":"2024-10-11T21:11:24.273Z","updated_at":"2025-04-05T23:09:24.153Z","avatar_url":"https://github.com/drupol.png","language":"PHP","readme":"[![Latest Stable Version](https://img.shields.io/packagist/v/drupol/phpermutations.svg?style=flat-square)](https://packagist.org/packages/drupol/phpermutations)\n [![GitHub stars](https://img.shields.io/github/stars/drupol/phpermutations.svg?style=flat-square)](https://packagist.org/packages/drupol/phpermutations)\n [![Total Downloads](https://img.shields.io/packagist/dt/drupol/phpermutations.svg?style=flat-square)](https://packagist.org/packages/drupol/phpermutations)\n [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/drupol/phpermutations/Continuous%20Integration?style=flat-square)](https://github.com/drupol/phpermutations/actions)\n [![Scrutinizer code quality](https://img.shields.io/scrutinizer/quality/g/drupol/phpermutations/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/drupol/phpermutations/?branch=master)\n [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/drupol/phpermutations/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/drupol/phpermutations/?branch=master)\n [![License](https://img.shields.io/packagist/l/drupol/phpermutations.svg?style=flat-square)](https://packagist.org/packages/drupol/phpermutations)\n [![Donate!](https://img.shields.io/badge/Donate-Paypal-brightgreen.svg?style=flat-square)](https://paypal.me/drupol)\n \n## PHPermutations\n\nPHP Iterators and Generators to generate combinations and permutations in an efficient way.\n\nAt first the library was created to only generate permutations and combinations.\n\nIn the end, I added other Iterators and Generators like:\n* Fibonacci numbers,\n* Perfect numbers,\n* Prime numbers,\n* Product of numbers,\n* Rotation of an array,\n* Cycling through an array,\n* Permutations,\n* Combinations,\n\n## Introduction\n\nI've always been fascinated by numbers and everything around them... in other words, mathematics.\n\nThe library has been written first for being used in [PHPartition](https://github.com/drupol/phpartition), then it has\nbeen extended here and there.\n\nIts main use is for generating Permutations and Combinations without running out of memory, thanks to\n[PHP Generators](https://secure.php.net/manual/en/language.generators.overview.php) and \nand [Iterators](https://secure.php.net/manual/en/class.iterator.php).\n\nThe difference with other combinatorics library is that you can use an extra parameter 'length', that allows you to\ncompute Permutations and Combinations of a particular size.\nThe other notable difference is that your input arrays may contains any type of object (integers, arrays, strings or\nobjects), the library will still continue to work without any trouble.\n\n## Requirements\n\n* PHP \u003e= 7.1.3,\n\n## How to use\n\nInclude this library in your project by doing:\n\n`composer require drupol/phpermutations`\n\nLet's say you want to find all the permutations of the list of number [1, 2, 3, 4, 5] having a length of 3:\n\n```php\n// Create the object\n$permutations = new \\drupol\\phpermutations\\Generators\\Permutations([1,2,3,4,5], 3);\n\n// Use a foreach loop.\nforeach ($permutations-\u003egenerator() as $permutation) {// do stuff}\n\n// Or get the whole array at once.\n$permutations-\u003etoArray();\n```\n\nMost of the components always has the same arguments except for very few of them.\n\nAs the documentation per component is not written yet, I advise you to\n[check the tests](https://github.com/drupol/phpermutations/tree/master/tests/src) to see how to use them.\n\n## Combinations\n\n\u003e In mathematics, a combination is a way of selecting items from a collection, such that (unlike permutations) the order\n\u003e of selection does not matter.\n\u003e  -- [_Wikipedia_](https://en.wikipedia.org/wiki/Combination)\n\nIn one sentence: _When the order doesn't matter, it is a Combination._\n\n## Examples\n\nLet's say we have a group of fruits:\n\n`$list = ['Apple', 'Pear', 'Banana', 'Orange']`\n\nand we want to find the combinations of length: `3`, the result will be:\n\n`['Apple', 'Pear', 'Banana']`\n\n`['Apple', 'Pear', 'Orange']`\n\n`['Apple', 'Banana', 'Orange']`\n\n`['Pear', 'Banana', 'Orange']`\n\n## Permutations\n\n\u003e In mathematics, the notion of permutation relates to the act of arranging all the members of a set into some sequence\n\u003e or order, or if the set is already ordered, rearranging (reordering) its elements, a process called permuting.\n\u003e These differ from combinations, which are selections of some members of a set where order is disregarded.\n\u003e  -- [_Wikipedia_](https://en.wikipedia.org/wiki/Permutation)\n\nIn one sentence: _When the order does matter, it is a Permutation._\n\n### Examples\n\nLet's say we have a group of fruits\n\n`['Apple', 'Pear', 'Banana', 'Orange']`\n\nand we want to find the permutations of length: `3`, the result will be:\n\n`['Apple', 'Pear', 'Banana']`\n\n`['Pear', 'Apple', 'Banana']`\n\n`['Apple', 'Banana', 'Pear']`\n\n`['Banana', 'Apple', 'Pear']`\n\n`['Pear', 'Banana', 'Apple']`\n\n`['Banana', 'Pear', 'Apple']`\n\n`['Apple', 'Pear', 'Orange']`\n\n`['Pear', 'Apple', 'Orange']`\n\n`['Apple', 'Orange', 'Pear']`\n\n`['Orange', 'Apple', 'Pear']`\n\n`['Pear', 'Orange', 'Apple']`\n\n`['Orange', 'Pear', 'Apple']`\n\n`['Apple', 'Banana', 'Orange']`\n\n`['Banana', 'Apple', 'Orange']`\n\n`['Apple', 'Orange', 'Banana']`\n\n`['Orange', 'Apple', 'Banana']`\n\n`['Banana', 'Orange', 'Apple']`\n\n`['Orange', 'Banana', 'Apple']`\n\n`['Pear', 'Banana', 'Orange']`\n\n`['Banana', 'Pear', 'Orange']`\n\n`['Pear', 'Orange', 'Banana']`\n\n`['Orange', 'Pear', 'Banana']`\n\n`['Banana', 'Orange', 'Pear']`\n\n`['Orange', 'Banana', 'Pear']`\n\nThe permutations of length 3 of the array [1, 2, 3, 4, 5] are, _please hold on tight_, the sum of all the permutations\nof each combinations having a length of 3 of that array.\n\n## Tests\n\nEach Generators and Iterators are tested using the same values as input. I try to be as much complete as possible with\nthe [tests](https://github.com/drupol/phpermutations/tree/master/tests/fixtures).\nEvery time the sources are modified, [Github](https://github.com/drupol/phpermutations/actions), the continuous integration\nservice, tests the code against those tests, this way you are aware if the changes that you are introducing are valid.\n\n# Contributing\n\nFeel free to contribute to this library by sending Github pull requests. I'm quite reactive :-)\n","funding_links":["https://github.com/sponsors/drupol","https://paypal.me/drupol"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrupol%2Fphpermutations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrupol%2Fphpermutations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrupol%2Fphpermutations/lists"}