hxtree/sumfinder
Composer 安装命令:
composer create-project hxtree/sumfinder
包简介
This program allows for an integer array to be passed in and will then output all the pairs that add up to the sum.
README 文档
README
SumFinder accepts an array of integers and finds which operands sum equals the desired value.
Usage
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 Composer
SumFinder is available on Packagist.
Install with Composer:
composer require hxtree/sumfinder
Examples
Learn how SumFinder can be used through our Docs.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-25