I'd like to roll up the ability scores for my Dungeons and Dragons character. But I'd also like them to be balanced (and slightly better than average).
Typically, a character's stats are created by rolling four 6-sided dice, adding together the three highest results, and doing this 6 times. A 6 sided die has the numbers 1 to 6, with equal probability of landing on each. The 6 scores can be in any order, and are typically displayed out in an array. Unfortunately, this has a slight pitfall, namely that some players' stats can be much higher than other players' stats.
So for this generator, the stats should be a little more balanced, namely that at least one stat should be less than or equal to a certain threshold, at least one stat should be greater than or equal to a certain threshold, and the total should be greater than or equal to a certain threshold. However, the randomness should still be preserved. If a generated stat array does not qualify, the entire array should be rerolled.
Given 3 inputs,
t, respectively corresponding to the low threshold, the high threshold, and the total threshold, output 6 stats (in any order) that meet the criteria. All 6 stats must be included. The stats should be randomly generated, using the stat generation described above.
l h t | low example | high example 10 15 75 | 6 14 18 12 10 15 | 10 18 18 18 18 18 8 18 80 | 10 18 16 13 8 15 | 18 18 18 8 18 18 18 18 108 | 18 18 18 18 18 18 | 18 18 18 18 18 18
The code doesn't need to be fast, it just needs to get there eventually. Note that formatting doesn't much matter. Assume valid inputs.