Subset Sum Solver

Find a subset of numbers that adds up to a target and count all the ways.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Step 1: Open Subset Sum Solver and add your input

    Type your numbers or text, add your file, or pick the options you need. Nothing is uploaded: everything stays in your browser.

  2. 2
    Step 2: What Subset Sum Solver does

    Find a subset of numbers that adds up to a target and count all the ways.

  3. 3
    Step 3: Read the result and compare

    The result appears at once. Change one value to see how the answer moves, then keep the figure that fits your case.

  4. 4
    Step 4: Copy or save it

    Copy the result or download it. For an important decision, confirm it with the official source or an adviser.

About this tool

Enter a list of positive whole numbers and a target. The solver finds a subset that sums exactly to the target and counts how many different subsets do.

Method

Dynamic programming over the possible sums: ways[s] counts the subsets with sum s, updated for each number. A subset is then reconstructed by walking back through the table.

Limits

Up to 60 numbers, each and the target up to 100,000. Equal numbers are treated as different items, so [5, 5, 5] with target 10 has 3 ways.

Worked example

From 3, 34, 4, 12, 5, 2 the target 9 is reached by 4 + 5 and by 3 + 4 + 2, so there are 2 ways.

Tips for best results

Check every box before you rely on a result, because one wrong digit changes the whole answer. Use the exact figures from your payslip, bill, certificate or contract, and keep a note of the date you calculated. Rates, thresholds and rules change from time to time, so for tax, fees and legal matters treat the output as an estimate and confirm with the official source named on this page. You can run as many scenarios as you like; nothing is saved or sent, and refreshing the page clears the boxes.

Quick facts

Embed this calculator on your site

Copy this code to show the calculator on your own page. A link back to shobfree.com is included.

Frequently asked questions

What if no subset works?

The result says none was found.

Can I use decimals or negatives?

No, only positive whole numbers.

Does each number get used once?

Yes, each list entry at most once.

How many ways are counted?

All subsets with that exact sum, as an exact integer.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages