To: Jerry Yu... Re: [ale] 2 Perl questions ?

Aditya Srinivasan sriad at uab.edu
Wed Dec 15 20:21:01 EST 2004


Courtney,


On Wed, 15 Dec 2004, Courtney Thomas wrote:

> Sriad,
> 
> I only want the 'picking' to simply be.... to merely add the file's 
> sizes until >650MB, then don't add the one that puts the total >650MB 
> and the 'moved-to' dir then contains that set the <=650MB, since each is 
> moved to the new 'container' dir, and the program stops.
> 
> Hope that clarifies my simple objective,
> Courtney

I understood this to mean, that you would like to continue this process 
until all files are in directories sized <=650MB.
If so, it is easy to end up with a very large number of directories

Consider 5 files :

1. 100 MB
2. 600 MB
3. 400 MB
4. 100 MB
5. 300 MB

The algo above would create :

dir 1 : 100 (600 pushes it over 650)
dir 2 : 600 (400 pushes it over 650)
dir 3 : 400 + 100 (300 pushes it over 650)
dir 4 : 300

Ideally it is possible to do this as :

dir 1: 100 + 400 + 100
dir 2: 600
dir 3: 300

ie. in 3 dirs instead of 4. If you have a larger number of files, you 
could end up with many directories like dir 1 (potentially underutilized)
The aim would be to keep the number of directories to a minimum (latter 
case)

Hope that explains what I was trying to get at.
Other replies in the thread describe simple and acceptable solutions to 
the problem (box packing problem).


Thanks,
sriad



More information about the Ale mailing list