1. Go to this page and download the library: Download mistralys/subsetsum library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mistralys / subsetsum example snippets
$sub = SubsetSum::create(25, array(5,10,7,3,20));
if(!$sub->hasMatches())
{
echo 'No matches.';
}
$matches = $sub->getMatches();
array(
array(3, 5, 7, 10),
array(5, 20)
)
// check if there are matches, since the method can return null.
if($sub->hasMatches())
{
$match = $sub->getShortestMatch();
}
// check if there are matches, since the method can return null.
if($sub->hasMatches())
{
$match = $sub->getLongestMatch();
}