I have a value, say 20010. I want to randomly divide this value over 24 hours. So basically split the value into a 24 slot big array where all slots are randomly big.
Wh
I tried the solutions from David and dahlbyk but had no luck. So here is what I came up with after reading the answer from mjv:
public static class IntExtensions
{
public static IEnumerable Split(this int number, int parts)
{
var slots = Enumerable.Repeat(0, parts).ToList();
var random = new Random();
while (number > 0)
{
var slot = random.Next(0, parts);
slots[slot]++;
number--;
}
return slots;
}
}