Tricky Distribution Algorithm needed

Discussion in 'Programming' started by michaeljc70, Apr 12, 2008.

  1. michaeljc70

    michaeljc70 New Member

    Joined:
    Apr 12, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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.

    Sample data

    Item Index Date
    0 4/1/08
    1 4/2/08
    2 4/3/08
    3 4/4/08
    4 4/5/08
    5 4/6/08
    6 4/7/08
    7 4/8/08
    8 4/9/08
    9 4/10/08

    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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice