mardi 11 août 2020

The best way to generate a randomised matrix in Java

So I'm using a preference matrix (2d array) within my program, in which each person ranks the other members from most favorable to least favorable. The individual ranks themselves last in the array.

For example:

{[1, 2, 3, 4, 5, 0],
 [2, 3, 4, 5, 0, 1],
 [3, 4, 5, 0, 1, 2],
 [4, 5, 0, 1, 2, 3],
 [5, 0, 1, 2, 3, 4],
 [0, 1, 2, 3, 4, 5]}

How can I randomly generate a matrix like the one above, where the last element represents the user's number 0-n and the remaining n-1 elements are arbitrary numbers in a random sequence?




Aucun commentaire:

Enregistrer un commentaire