News for hackers. Stuff that matters.
Re:I analyzed shuffling in a million games of MtG Arena by andromeduck on Sunday January 15, 2023 @08:09AM (#34389130)
The n-2 bit is unnecessary and misleading because we've already established that an index can be swapped with itself.

for i in [0..n-1] swap(a[i], a[rand in [i..n-1])

where rand in [I..n-1] coud be implemented as i + (rand() % (n-i))

essentially start with your finger at 0, pick a card from the unpicked set which is everything on and after your finger, swap that card with your finger, move your finger up one card

There are no comments on this comment yet.