mardi 5 avril 2016

Create a random generator for a range [min, max] given a 0/1 random generator

Given a random generator, which generate 0 or 1 with the same probability, how to create a random generator int generateRandom(int min, int max)which generate a random number with he same probability in a range [min, max]?

If this function would be called multiple times with arbitrary min and max, how to optimize it to improve the time efficiency?




Aucun commentaire:

Enregistrer un commentaire