https://github.com/hxtree/sumfinder
SumFinder is a simple library for finding integers in an array that equal a sum
https://github.com/hxtree/sumfinder
Last synced: about 2 months ago
JSON representation
SumFinder is a simple library for finding integers in an array that equal a sum
- Host: GitHub
- URL: https://github.com/hxtree/sumfinder
- Owner: hxtree
- License: mit
- Created: 2020-02-25T07:17:11.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-26T02:11:26.000Z (about 5 years ago)
- Last Synced: 2025-02-12T10:34:42.764Z (3 months ago)
- Language: PHP
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SumFinder
***SumFinder*** accepts an array of integers and finds which operands sum equals the desired value.

[](https://app.codacy.com/manual/hxtree/sumfinder?utm_source=github.com&utm_medium=referral&utm_content=hxtree/sumfinder&utm_campaign=Badge_Grade_Dashboard)## Usage
```php
require __DIR__ . '/../vendor/autoload.php';$sum_finder = new SumFinder();
$sum_finder->setSumValue(10);
$sum_finder->setIntArray(1,1,2,4,4,5,5,5,6,7,9);/*
* output all pairs (includes duplicates and the reversed order pairs)
* [1,9], [1,9], [4,6], [4,6], [5,5], [5,5], [5,5], [5,5], [5,5], [5,5]
*/
echo $sum_finder->getAllPairs() . PHP_EOL;/*
* output unique pairs only once (removes the duplicates but includes the reversed ordered pairs)
* [1,9], [4,6], [5,5], [6,4], [9,1]
*/
echo $sum_finder->getUniquePairs() . PHP_EOL;/*
* output the same combo pair only once (removes the reversed ordered pairs)
* [1,9], [4,6], [5,5]
*/
echo $sum_finder->getComboPairs() . PHP_EOL;```
## Installation
Via ComposerSumFinder is available on [Packagist](https://packagist.org/packages/hxtree/sumfinder).
Install with Composer:
```shell script
composer require hxtree/sumfinder
```## Examples
Learn how SumFinder can be used through our [Docs](docs/README.md).