Ecco: sono riuscito a costruire una routine che, credo, operi secondo questo algoritmo:
Sub funzione() Dim carte(3) As Integer carte(0) = 123 carte(1) = 234 carte(2) = 345 carte(3) = 456 Dim i As Integer, j As Integer Dim tampone As Integer i = 3 Do While i <> 0 j = Int(Rnd() * i) tampone = carte(j) carte(j) = carte(i) carte(i) = tampone i = i - 1 Loop For k = 0 To 3 Debug.Print carte(k) Next k Debug.Print "----------------------" End SubEd ecco una serie di "rimescolamenti"
345 456 234 123 ---------------------- 234 456 123 345 ---------------------- 456 123 234 345 ---------------------- 456 123 234 345 ---------------------- 234 456 123 345 ---------------------- 234 456 123 345 ---------------------- 456 345 123 234 ---------------------- 456 345 123 234 ---------------------- 456 123 234 345 ---------------------- 456 123 234 345 ---------------------- 456 123 234 345 ---------------------- 456 345 123 234 ---------------------- 234 456 123 345 ---------------------- 234 345 456 123 ---------------------- 234 345 456 123 ---------------------- 456 345 123 234 ---------------------- 234 456 123 345 ---------------------- 234 345 456 123 ----------------------Sembra che siano abbastanza "casuali"!
Nessun commento:
Posta un commento