Shuffle Board

Publicado 2023-06-12


I was reading earlier about the Fisher-Yates Shuffle method and - well, I'm a little confused. What is the purpose of its complexity ?

I mean if you just want to shuffle a deck of cards, for instance, you can do so in code as simple as this:

In the Fisher-Yates method you are expected to use a technique that involves saving every single element that was chosen so it will not be chosen again.

What if any are the advantages of using a shuffle such as this based on a simple single-array index-swap as seen above ?

Failing that, what is YOUR method for shuffling items in an array that satisfy you they are properly scrambled ?