-> Calls: 1 Depth: 1 Share: [ ] Target: 5 Treasures: [ 50 2 4 3 1 2 4 8 ] ... Putting "50" into the share, leaving treasures [ 2 4 3 1 2 4 8 ] --> Calls: 2 Depth: 2 Share: [ 50 ] Target: -45 Treasures: [ 2 4 3 1 2 4 8 ] ... Returning undef because target < 0 -> Situation failed. Couldn't hit target. Omitting treasure [ 50 ] and backtracking to target of 5, treasures [ 2 4 3 1 2 4 8 ] at depth 1 --> Calls: 3 Depth: 2 Share: [ ] Target: 5 Treasures: [ 2 4 3 1 2 4 8 ] ... Putting "2" into the share, leaving treasures [ 4 3 1 2 4 8 ] ---> Calls: 4 Depth: 3 Share: [ 2 ] Target: 3 Treasures: [ 4 3 1 2 4 8 ] ... Putting "4" into the share, leaving treasures [ 3 1 2 4 8 ] ----> Calls: 5 Depth: 4 Share: [ 2 4 ] Target: -1 Treasures: [ 3 1 2 4 8 ] ... Returning undef because target < 0 ---> Situation failed. Couldn't hit target. Omitting treasure [ 4 ] and backtracking to target of 3, treasures [ 3 1 2 4 8 ] at depth 3 ----> Calls: 6 Depth: 4 Share: [ 2 ] Target: 3 Treasures: [ 3 1 2 4 8 ] ... Putting "3" into the share, leaving treasures [ 1 2 4 8 ] -----> Calls: 7 Depth: 5 Share: [ 2 3 ] Target: 0 Treasures: [ 1 2 4 8 ] ... Returning "[]" because target == 0 A recursive call at depth 5 found that a solution of [ 3 ] adds up to my target of 3 at depth 4 A recursive call at depth 3 found that a solution of [ 2 3 ] adds up to my target of 5 at depth 2 Solution: 2 3