I have a bag with 100 potatoes. I need to split the potatoes in N number of buckets. In each bucket I must have between 15 and 60 potatoes.

Obviously, I need a step by step solution to make this into code.

The best way that I have so far:

Minimum number of buckets: 100/60 = 1 (40) => round it up => 2  

Maximum number of buckets: 100/15 = 6 (10) => round it down => 6

So you can have a minimum of 2 and maximum of 6 buckets. Now we pick a random number (because I need only one solution, not all of them).

Let's pick 3.  

Potatoes per bucket: 100/3 = 33 (1)  

Buckets: 33, 33, 34.

Now here is the tricky part. While this IS a solution to the original problem, it doesn't work for me, because I need the numbers to be more random than that. In the problem the condition was 15-60 but here we get only 33-34, which is too uniform for what I need.

One of the solutions from here could be to start adding and subtracting numbers from each bucket. Probably do this for 10 iterations or so, but I reckon there must be a better way to do it.

Any ideas?