mercredi 28 septembre 2016

How to randomly generate a float between two values with a variable number of ranges excluded?

For example, if I wanted to generate a random float between 0 - 100, but exclude the values 1.097 - 3. 346, 7.0001 - 8.9996, 14.5 - 38.6, 50 - 50.389, 75.648 - 88.8975, etc? I thought this would be a simple problem, but there doesn't even seem to be Range object in c#, and there is no RandWithExclusion() method.

I have seen all these questions,
How can I generate a random number within a range but exclude some?
http://ift.tt/2cLRJNE
How to get a random number from a range, excluding some values
none of them are even remotely useful. Is what I'm doing really such a rare problem?

How would I even go about doing this? (Without brute-forcing, please.)




Aucun commentaire:

Enregistrer un commentaire