Skip to content

The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence—in plain terms, the algorithm shuffles the sequence. 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 …

License

Notifications You must be signed in to change notification settings

CorvusCodex/Fisher-Yates-JS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Fisher-Yates-JS

The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence—in plain terms, the algorithm shuffles the sequence. 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.

How to use:

ADD SCRIPT TO HEAD OF YOUR WEBSITE:

If using downloaded version:

<script src="fisher-yates.js"></script>

Using CDN Version:

<script src="https://cdn.jsdelivr.net/gh/AlturaDesigner/Fisher-Yates-JS@master/fisher%E2%80%93yates.js"></script>

Create array: var newarray = [1,2,3,4,5,6,7,8,9,10];

The simply call shuffle function:

newarray = shuffle(newarray);

That's it!

About

The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence—in plain terms, the algorithm shuffles the sequence. 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 …

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published