jeudi 26 juillet 2018

How to select a random member of a javascript array with n members such that every selection is as far as possible from the previous 3 selections?

Suppose there is an array with 50 elements. Every time a random element is selected (all selected elements are still eligible for re-election in the subsequent iterations), is there a way to make sure that these new selections are as "far" as possible from the three items that were selected before it? Of course, this won't matter for the first three iterations.

By "far" I mean as distant (neighbour-wise) as possible from the previous 3 selections.

I am not sure if I make sense so feel free to correct any misconception I may display.




Aucun commentaire:

Enregistrer un commentaire