This is an algorithm made from scratch that lists all possible patterns given a candidate list of numbers that add to a certain sum.
-
Edit LINE 2 of the numberselect.txt file and enter the candidate numbers separated by a space. Ex. 9 12 4 3
-
Edit LINE 4 of the same file and enter the sum that the candiates may add to.
-
Save the file
-
Compile
g++ main.cpp -
Run
./a.out //For Unix ./a.exe //For Windows
Inside numberselect.txt File:
1 Enter the candidate numbers separated by a space: Ex. 1 9 12 14
2 1 2 3 //User Input
3 Enter the Sum: Ex. 13
4 4 //User Input
Combination:
1 1 1 1
Combination:
2 1 1
Combination:
1 2 1
Combination:
3 1
Combination:
1 1 2
Combination:
2 2
Combination:
1 3
- Potentially check if the user did not enter two of the same numbers in the txt file.