Re: Summing combinations to a known total problem, for cash-allocation / open-item accounting
- From: "Randy Poe" <poespam-trap@xxxxxxxxx>
- Date: 1 Apr 2005 12:05:31 -0800
stephen@xxxxxxxxxx wrote:
> Dave Lomax <billy_boy_clinton@xxxxxxxxxxx> wrote:
> : Hi Randy,
>
> : Thanks for your help. Unless I'm missing something, this method is
> : basically a "decision tree"?
I just reread your original post and realized I misread
the problem. What I gave you was a "change-making"
solution, which will turn out such things as
125 = 25+25+25+25+25.
This is achieved in the recursion by trying from
0 up to the maximum number of times the current
value will fit (if trying to fit [30 25] into 125,
try 0 30s, 1 30, 2 30s, 3 30s, 4 30s).
It looks like in your case that you only need to
try the possibilities of 0 or 1. Same basic recursion,
but fewer times through the loop at each level. My
algorithm ran through the change-making for the sample
problem in 15 function calls to generate all 3
possible solutions. With this modification, this
would probably be cut in half.
- Randy
.
- Follow-Ups:
- References:
- Prev by Date: Re: problem 'getting into' the spirit of abstract algebra
- Next by Date: 'Integral test'-related counterexample
- Previous by thread: Re: Summing combinations to a known total problem, for cash-allocation / open-item accounting
- Next by thread: Re: Summing combinations to a known total problem, for cash-allocation / open-item accounting
- Index(es):