Calc Invoices to Pay?

Stanley Barnett stanley at stanlyn.com
Thu Mar 13 05:15:27 PDT 2008


>     Put the numbers into an array of size N.
>     Loop X from 0 to 2^N-1.
>         Init sum to zero.
>         Loop Y from 0 to N-1.
>             If bit Y is set in X, add invoice[Y] to sum.
>         Check if sum is desired about.

What would the filepro code look like?


> With only 11 invoices, it only took a fraction of a second to loop
through the 2,048
> combinations.  Of course, if you have 35 invoices, checking all
> 34,359,738,368 combinations using this method may take some time.

How long would it take filepro to do this?  


> Total time to get the computer to tell me there were no matches found:
> about 5 minutes.

Did this include creating the C program?

Thanks,
Stanley Barnett  -  stanley at stanlyn.com
Stan-Lyn & Associates, Inc.  -  http://www.StanLyn.com
Office: (859) 402-8165  -  Cell: (606) 568-5412




-----Original Message-----
From: Kenneth Brody [mailto:kenbrody at bestweb.net] 
Sent: Friday, March 07, 2008 10:14 AM
To: Stanley Barnett
Cc: filepro-list at lists.celestial.com
Subject: RE: Calc Invoices to Pay?

Quoting Stanley Barnett (Thu, 6 Mar 2008 21:36:37 -0500):

>> The reason you spent a long time searching for the right combination
> and not finding
>> it is because there is no combination that matches those amounts.
>
> The little routing I'm asking for should be able to tell me that in a 
> second or two, therefore saving me the wasted time I spent looking.
>
> BTW, I talked to the customer today and learned that he had split some

> invoices across the 2 payments (checks).  That's perfectly fine, but 
> if I had known that from the beginning I would not have spent the time

> on it, instead I would have called him for the details.  The code I'm 
> looking for should have quickly figured it out as both you and I did 
> and issue a message box saying no combination could be found.
>
> How long did you spend searching for a combination?  Did you test all 
> possible combinations?  And, how did you test?
[...]

Well, I was on my new laptop, which doesn't yet have filePro on it, so I
"cheated" and wrote a C program.

Since there were only 11 invoices, I simply calculated all 2048
different combinations, and checked for the desired values.  When it
didn't find any, I had it write the sums to a file, sorted the output,
and manually looked for the desired values.  (And, of course, still
didn't find them.)

Basic logic:

     Put the numbers into an array of size N.
     Loop X from 0 to 2^N-1.
         Init sum to zero.
         Loop Y from 0 to N-1.
             If bit Y is set in X, add invoice[Y] to sum.
         Check if sum is desired about.

With only 11 invoices, it only took a fraction of a second to loop
through the 2,048 combinations.  Of course, if you have 35 invoices,
checking all
34,359,738,368 combinations using this method may take some time.

Total time to get the computer to tell me there were no matches found:
about 5 minutes.

Total time to manually re-check: less than 5 more minutes.

-- 
KenBrody at BestWeb dot net        spamtrap:
<g8ymh8uf001 at sneakemail.com>
http://www.hvcomputer.com
http://www.fileProPlus.com


More information about the Filepro-list mailing list