Let's say I have the following matrix
arr1[0,$i] = 0,0,0,0,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3
arr1[1,$i] = 0,0,0,1,1,1,1,1,2,2,2,3,3,3,4,4,4,4,5,5
arr1[2,$i] = 0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,2,2,2
arr1[3,$i] = 0,0,1,1,2,2,3,3,3,4,4,4,5,5,5,6,6,6,6,6
I want to obtain a matrix that has the same number of rows and columns as the original one but with randomized elements that fulfils the following 2 conditions:
- Each row of arr2 has to heave the same elements as arr1 but in a random order.
- All columns of arr2 should be unique.
Example:
arr2[0,$i] = 0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,1,2,3,2
arr2[1,$i] = 0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,1,4,1
arr2[2,$i] = 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,2,0,2,2
arr2[3,$i] = 0,1,2,3,4,5,6,0,1,2,3,4,5,6,3,4,5,6,6,6
Aucun commentaire:
Enregistrer un commentaire