Skip to main content
100%

The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite set—in plain terms, the algorithm shuffles the set. The algorithm effectively puts all the elements into a hat; it continually determines the next element by randomly drawing an element from the hat until no elements remain. The algorithm produces an unbiased permutation: every permutation is equally likely. The modern version of the algorithm is efficient: it takes time proportional to the number of items being shuffled and shuffles them in place https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle

✓ Published0🌍 Public
HHugoberry
Last edited Feb 1, 2017
Created on Feb 1, 2017

This visualization demonstrates the Fisher–Yates shuffle algorithm by animating its in-place swapping process across a list of numeric values. It shows how each iteration randomly selects an unshuffled position and exchanges it with the current index, progressively building a random permutation. The implementation uses a custom `swap` function built from Power Query’s `List.Range` and `List.Buffer` operations, with `Number.RandomBetween` driving the random selection. The code, written in the M language, relies on `List.Accumulate` to iterate through the list, highlighting the algorithm’s efficiency and unbiased nature without external libraries.

AI-generated description

Similar vizzes