1
$\begingroup$

I'm given a number (n), an interval (i), and the number of steps (s). I want to distribute these numbers over that criteria as best as possible. The upper bounds would be n (which is critical) and lower bounds is greater than or equal to 0.75 * n (but divisible by the interval). So, if n=100, i=5, and s=6, you'd have [100, 95, 90, 85, 80, 75]. This one is easy because 100*.75 is <= s*i. How would you do n=25, i=2.5, and s=6?

This was a problem I came across while programming and was wondering if there was some mathematical concept that fit this problem.

Also, I had no idea what to tag this under.

2 Answers 2

2

If I understand you, the ideal situation is to have your set be $[n, n-i, n-2i, \ldots,n-(s-1)i]$, which has s members. To keep this within the top $0.75n$, you need $(s-1)i\leq .25n$, which is just satisfied in your first example. In your second it is not, so you need to decide what to give up. You could forget about the 0.75 criterion and keep the interval, giving $[25, 22.5, \ldots,12.5]$ Or you could maintain the 0.75 criterion and reduce the step size, giving an interval of 1.25.

  • 0
    @J.M.: seems to work. I'll use that next time. Thanks2010-12-07
0

in R:

seq(from=25, by=-2.5, length=6)