" 3. This recursive routine works in the reverse order from the last (and highest point of array). "
But it could equally be done by working from the lowest to the highest. So how could it be established (maybe not possible) whether it is quicker to work from the top or from the bottom?
(And what about the run time if there is no match!)
The thing that's being overlooked is that the original question wants a routine to match payments against invoices.
W. Pooh has indicated that this is not a practical or worthwhile target - I agree with him.
Sorting by invoice value can(should) substantially reduce the number of combinations to be checked but it will not necessarily produce results that will represent matches in ascending order by invoice date - which surely must be important.
If it's not important, what's the relevance to accounts receivable and why bother trying to match at all?
If it is important, whatever the match happens to be, the payer needs to be asked if the correct invoices are being matched. So why bother to attempt a match - just either ask the payer or set off against the earliest invoces.
Jay Petrulius has said that the challenge is appropriate for identifying errors in a particular situation that he describes.
OK, but this is not what the challenge has asked for.
Different considerations are involved in developing a procedure for J. Petrulius' scenario versus the scenario set by the monthly challenge.
Perhaps the challenge should drop the association with invoices/accoumts receivable, and merely ask for a solution to match a given amount with a range of numbers in any sequence.
That being the case, good luck!
I shall certainly not be wasting any of my time on it.
But it could equally be done by working from the lowest to the highest. So how could it be established (maybe not possible) whether it is quicker to work from the top or from the bottom?
(And what about the run time if there is no match!)
The thing that's being overlooked is that the original question wants a routine to match payments against invoices.
W. Pooh has indicated that this is not a practical or worthwhile target - I agree with him.
Sorting by invoice value can(should) substantially reduce the number of combinations to be checked but it will not necessarily produce results that will represent matches in ascending order by invoice date - which surely must be important.
If it's not important, what's the relevance to accounts receivable and why bother trying to match at all?
If it is important, whatever the match happens to be, the payer needs to be asked if the correct invoices are being matched. So why bother to attempt a match - just either ask the payer or set off against the earliest invoces.
Jay Petrulius has said that the challenge is appropriate for identifying errors in a particular situation that he describes.
OK, but this is not what the challenge has asked for.
Different considerations are involved in developing a procedure for J. Petrulius' scenario versus the scenario set by the monthly challenge.
Perhaps the challenge should drop the association with invoices/accoumts receivable, and merely ask for a solution to match a given amount with a range of numbers in any sequence.
That being the case, good luck!
I shall certainly not be wasting any of my time on it.