I am trying to distribute values over a specific number of value holders based on the values of Start and End.
If the number of value holders is equal to the difference between the starting and ending values, it will just be an iteration:
Start Value : 1
End Value : 10
Value Holders: 10
|
Expected Result: 1 2 3 4 5 6 7 8 9 10
If the number of value holders is less than the difference between the initial and final values, we need to skip some numbers. The goal is to try to distribute the values as evenly as possible.
NOTE. Relying on neither the right nor the left is not important :)
Start Value : 1
End Value : 10
Value Holders: 5
|
Expected Result: 1 3 5 8 10
or
1 3 6 8 10
Start Value : 1
End Value : 10
Value Holders: 3
|
Expected Result: 1 5 10
or
1 6 10
If the number of value holders is greater than the difference between the start and end values, we will repeat some numbers.
Start Value : 1
End Value : 10
Value Holders: 15
|
Expected Result: 1 2 3 4 4 5 5 6 6 7 7 8 8 9 10
(or something similar)
How can I implement this in C #?
source
share