3 ms·
For those interested, I wrote a small article on the various was of writing incorrect Fisher-Yates [0]. The post also covers generating single cycle permutation
by abetusk 4y ago
For those interested, I wrote a small article on the various was of writing incorrect Fisher-Yates [0]. The post also covers generating single cycle permutations.
Fisher-Yates is pretty obvious but weirdly subtle in some ways. For someone not paying attention, it would be easy to get wrong, as the grandparent response points out.
[0] https://mechaelephant.com/dev/Fisher-Yates-Shuffle.html https://mechaelephant.com/dev/Fisher-Yates-Shuffle.html
- vmilner 4y agoInterestingly the method used to deal bridge hands for top tournaments doesn’t shuffle at all, it generates a random number between 1 and 52!/(13!^4) and maps that number to a corresponding deal of the cards.
- LudwigNagasena 4y agoAre you sure they do bijective mapping instead of simply running a RNG with the given seed?
- vmilner 4y agoYes - see the “Making bridge deals” section of: https://sater.home.xs4all.nl/doc.html https://sater.home.xs4all.nl/doc.html