When trying to create an array that contains random non-repeated values (meaning every value is unique in the array) the problem I run into is that the program is doing calculations all the time and takes TOO long to print out the array, which makes perfect sense considering that in an array of 5 cells, the probability of generating a new value between the narrow range of [0,10] is gradually decreasing after every success. Is there any quicker way or algorithm to prevent the computer from generating the same value over and over again, and ensure the result within a reasonable amount of time?
lundi 6 septembre 2021
Generate array with random non-repeated values [duplicate]
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire