Assume: I have a number of folders in a main directory. Each folder has at least one or more files in them, in varying sizes. So the total file size contained in each of the folders can vary, like so:
[0] => Folder 1, 701 mb
[1] => Folder 2, 696 mb
[2] => Folder 3, 1.09 gb
[3] => Folder 4, 723 mb
[4] => Folder 5, 3.07 gb
[5] => Folder 6, 699 mb
[6] => Folder 7, 701 mb
[7] => Folder 8, 699 mb
[8] => Folder 9, 700 mb
[9] => Folder 10, 791 mb
[10] => Folder 11, 701 mb
[11] => Folder 12, 701 mb
...
At any given time, my main directory can contain an aggregate of maybe 10 gb or so. Maybe 20 gb. Maybe 40 gb. As I said, it varies.
Now, I want to burn folders and files into a dvd disk. I wish to back up my files, you see.
So my problem is: which combination of the folders gives a 'best fit' into a blank dvd, given that a blank dvd can contain 4.7 gb?
So, for example, I try combining Folders 1, 2, 3, 4 and 12:
[0] => Folder 1, 701 mb
[1] => Folder 2, 696 mb
[2] => Folder 3, 1.09 gb
[3] => Folder 4, 723 mb
[11] => Folder 12, 701 mb
TOTAL: 3.85 GB
Which fits nicely into my blank dvd, sure.
But if I try Folders 7 to 12:
[6] => Folder 7, 701 mb
[7] => Folder 8, 699 mb
[8] => Folder 9, 700 mb
[9] => Folder 10, 791 mb
[10] => Folder 11, 701 mb
[11] => Folder 12, 701 mb
TOTAL: 4.19 GB
I am able to fit more into my dvd and therefore maximize the use of one blank disc. But which other combinations are better?
Granted that via php I can put all folder items in my main directory into an array like above, I need to generate possible combinations of folders per compilation, get the total size of each compilation and compare them with each other. And that's where I'm stumped at.
I think that my problem is essentially the same as RR_QQ's, as far as figuring out different combinations or permutations of my subfolders. And I think it's practical enough for most people.
So any takers?