?

Log in

No account? Create an account

July 10th, 2007

We are all geeks

gdmusumeci pointed me at this XKCD comic:

He laughed at himself at what a geek he was for actually solving it, which only egged me on, of course, and then I had to waste a good ten minutes of work solving it myself. I spent a minute trying to finesse it before realizing, duh, the knapsack problem is NP-Complete, there ISN'T any way to finesse it, only this way:

Warning very ugly code behind this cutCollapse )

$ perl app.pl
got it: 15.05,  1 0 0 2 0 1
$

So, the (unique) answer is one mixed fruit, two hot wings, and a sampler plate. And thus was I able to proceed with my work.

EDIT: That solution is not unique; there is another, completely obvious solution of seven mixed fruits. See the comments for the geekery of why this script misses that answer. Grr.

Profile

14L
szasz
Charley

Latest Month

July 2013
S M T W T F S
 123456
78910111213
14151617181920
21222324252627
28293031