Tricky Distribution Algorithm needed
I am writing a utility that deletes files based on a few factors. For this, I am allowing the number of files to keep and a distribution factor. The distribution factor is 1 to 10 and determines if the distribution of files to keep should skew toward older or newer files.
For example, if there are 10 files and you want to keep 4 and the distribution is 2, more old files would be kept than new ones. If the distribution factor is 5, you would keep an equal number of (alternating) older and newer files. This doesn't have to be exact, but in any case it should keep the oldest and newest file.
My issue is coming up with an algorithm to pick which files to delete. I am thinking
I need to use exponents or something, but haven't go anything to work. This is being done in C# with arrays.
I am giving a few examples of what I would expect for results. In this example there are 10 files. This number definitely can vary. In this example, I am assuming 5 files are to be kept.
Item Index Date
Results for Distribution Index 3: Keep Item 0,1,3,6,9
Results for Distribution Index 5: Keep Item 0,2,4,7,9
Results for Distribution Index 8: Keep Item 0,3,6,8,9
Results for Distribution Index 10: Keep Item 0,6,7,8,9
|All times are GMT +5.5. The time now is 18:30.|