\$ perl find_shares_myway_2.pl Trying to hit target of 7... -> Call 1 Depth: 1 Trial set: [ ] Remaining: [ 2 3 4 5 1 ] ... 0 < 7, so I put "2" into the trial set, and now I'll recurse --> Call 2 Depth: 2 Trial set: [ 2 ] Remaining: [ 3 4 5 1 ] ... 2 < 7, so I put "3" into the trial set, and now I'll recurse ---> Call 3 Depth: 3 Trial set: [ 2 3 ] Remaining: [ 4 5 1 ] ... 5 < 7, so I put "4" into the trial set, and now I'll recurse ----> Call 4 Depth: 4 Trial set: [ 2 3 4 ] Remaining: [ 5 1 ] ... Returning undef because trial set total 9 > 7 ---> Situation failed. Omitting treasure [ 4 ] and backtracking to choices of [ 5 1 ] at depth 3 ----> Call 5 Depth: 4 Trial set: [ 2 3 ] Remaining: [ 5 1 ] ... 5 < 7, so I put "5" into the trial set, and now I'll recurse -----> Call 6 Depth: 5 Trial set: [ 2 3 5 ] Remaining: [ 1 ] ... Returning undef because trial set total 10 > 7 ----> Situation failed. Omitting treasure [ 5 ] and backtracking to choices of [ 1 ] at depth 4 -----> Call 7 Depth: 5 Trial set: [ 2 3 ] Remaining: [ 1 ] ... 5 < 7, so I put "1" into the trial set, and now I'll recurse ------> Call 8 Depth: 6 Trial set: [ 2 3 1 ] Remaining: [ ] ... Returning undef because no available choices remain and 6 < 7 -----> Situation failed. Omitting treasure [ 1 ] and backtracking to choices of [ ] at depth 5 ------> Call 9 Depth: 6 Trial set: [ 2 3 ] Remaining: [ ] ... Returning undef because no available choices remain and 5 < 7 --> Situation failed. Omitting treasure [ 3 ] and backtracking to choices of [ 4 5 1 ] at depth 2 ---> Call 10 Depth: 3 Trial set: [ 2 ] Remaining: [ 4 5 1 ] ... 2 < 7, so I put "4" into the trial set, and now I'll recurse ----> Call 11 Depth: 4 Trial set: [ 2 4 ] Remaining: [ 5 1 ] ... 6 < 7, so I put "5" into the trial set, and now I'll recurse -----> Call 12 Depth: 5 Trial set: [ 2 4 5 ] Remaining: [ 1 ] ... Returning undef because trial set total 11 > 7 ----> Situation failed. Omitting treasure [ 5 ] and backtracking to choices of [ 1 ] at depth 4 -----> Call 13 Depth: 5 Trial set: [ 2 4 ] Remaining: [ 1 ] ... 6 < 7, so I put "1" into the trial set, and now I'll recurse ------> Call 14 Depth: 6 Trial set: [ 2 4 1 ] Remaining: [ ] ... Found solution: [ 2 4 1 ] == 7 ----->A recursive call at depth 6 found that a solution } of [ 2 4 1 ] adds up to my target of 7 at depth 5 --->A recursive call at depth 4 found that a solution } of [ 2 4 1 ] adds up to my target of 7 at depth 3 ->A recursive call at depth 2 found that a solution } of [ 2 4 1 ] adds up to my target of 7 at depth 1 Solution: [ 2 4 1 ]