[quote]…such that pit 5-7 are never empty.
[/quote]
Hm… that’s an odd requirement.
int pitCount = 7;
int seedCount = 16;
int mandatoryPits = 3;
int[] pits = new int[pitCount];
Random r = new Random(...);
// put 16-3=13 seeds in 7 pits
for(int i=0; i<seedCount - mandatoryPits; i++) {
pits[r.nextInt(pitCount)]++;
}
// for the last 3 seeds, ensure that pit 5,6,7 are not empty
// if already not empty, just put the seed in a random pit
for(int p=pitCount-mandatoryPits; p<pitCount; p++) {
if(pits[p] == 0) {
pits[p] = 1;
}
else {
pits[r.nextInt(pitCount)]++;
}
}
// this is more 'random' than pre-filling pit 5,6,7 with seeds,
// and then randomly distributing the remaining 13 seeds
:persecutioncomplex: