I have a list of size 202 with the integers 0...201. I need to iterate through this list and for each element I need to choose 4 elements with one being the current element and the remaining 3 being random, nonrepeating elements.
For example,
At the first iteration I need to generate [0, r1, r2, r3] where r1, r2, r3 are distinct random numbers between 1-201;
At the second iteration I need to generate [1, r1, r2, r3] where r1, r2, r3 are distinct random numbers between 0, 2-201;
At the third iteration I need to generate [2, r1, r2, r3] where r1, r2, r3 are distinct random numbers between 0-1, 3-201;
I know a way to do this but it takes too much time and space and since I will be doing this in the main thread of an android app I should probably do something more efficient.
Aucun commentaire:
Enregistrer un commentaire