This question already has an answer here:
- Creating random numbers with no duplicates 15 answers
- Random shuffling of an array 19 answers
- Java generating non-repeating random numbers 6 answers
How can I randomly select elements from an array and move them to different smaller arrays with no repetition.
For example my original array has the numbers 1-52 in it (representing each card in a standard deck). I want to randomly place each card in a pile without any repetition (like a game of solitaire).
Is there a a function for random selection like this?
Aucun commentaire:
Enregistrer un commentaire