Skip to content

Latest commit

 

History

History
28 lines (16 loc) · 777 Bytes

FisherYatesShuffle.md

File metadata and controls

28 lines (16 loc) · 777 Bytes

Fisher Yates shuffle

The easy way shuffles the cards.

The Fisher-Yates shuffle is an algorithm for generating a random permutation of a finite sequence - in plain terms, the algorithm shuffles the sequence.

Example:

use Gambling\Tech\FisherYatesShuffle;

$cards = [0, 1, 2, 3, 4, 5, 6, 7];

$shuffled = (new FisherYatesShuffle())($cards);

$shuffled; // [7, 2, 1, 5, 4, 6, 0, 3]

Implementation in file FisherYatesShuffle.php


Algorithms | Go back