Monday, October 31, 2011

Less talking, more doing

And now I'll violate that by writing about it. I had a partial payment from a customer today with whom I have about 10 open invoices, and there was no telling which invoices the payment was intended to cover. After dithering, I decided that really I should be able to write a brute-force knapsack search to find if there was any combination that matched. (Turns out there wasn't, but there was a combination that came within 2 Euros, so at least I can flag something as paid in the database, close enough.)

It took me about an hour, which is pretty damned pathetic, really. About two minutes of that was realizing it was a recursive problem, and 58 minutes was spent debugging it. I'm pretty sure that I could come up with a programming system that would allow me to express this algorithm without being quite so brittle in its implementation. I mean, essentially that's what I want to do in the first place here.

To that end, I'm wondering if I shouldn't start looking for this kind of algorithmic problem and implement more of them. At least I'd stop dithering about whether it was a good use of time or not. I'll bet I could shave most of those 58 minutes off, anyway.

No comments:

Post a Comment