I need a function like
int f(int min, int max, int x, int chance)
// where accepted chance values are 0 to 100 and x values are min to max
to return a random integer equal or greater than min, smaller or equal to max with chance% probability of the result to equal x and 100-chance% probability spread uniformly among all other results in the given range.
My solution is to create an array of 100 cells, fill it with random domain-compliant non-x-equal numbers, throw-in chance number of x-equal values and take a value of a random cell. But I believe there is to be a much better solution a better educated developer can suggest. Can you?
Might be an offset by one error somewhere