Re: 0/1 knapsack-like minimalization problem and
- To: mathgroup at smc.vnet.net
- Subject: [mg108816] Re: 0/1 knapsack-like minimalization problem and
- From: dr DanW <dmaxwarren at gmail.com>
- Date: Thu, 1 Apr 2010 06:02:32 -0500 (EST)
- References: <hosi6n$o6a$1@smc.vnet.net>,<201003311027.FAA09377@smc.vnet.net>
Ok, I admit that I was only looking at the first part of the problem, not the extension of the problem. I am also assuming that you have already used FileNames[] and FileByteCount[] to get the information in a list {size -> filename, ...} In[1]:= list = {3.4 -> "File1", 2.1 -> "File2", 6.5 -> "File3", 4.2 -> "File4"}; In[2]:= dist[a_, b_] := If[a <= b, b - a, 10*^10] In[3]:= Nearest[list, 3.3, DistanceFunction -> (dist[#2, #1] & )] Out[3]= {"File2"} The dist[] function is to take care of the less than condition. There may be more elegant ways of doing this. Daniel