-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathshuffle.theory.txt
21 lines (18 loc) · 1.53 KB
/
shuffle.theory.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
┏━━━━━━━━━━━━━┓
┃ SHUFFLE ┃
┗━━━━━━━━━━━━━┛
SORT SHUFFLE ==> #Assign a random number to each element
#Sort list using that random number as key
KNUTH SHUFFLE ==> #Incrementally build output by extracting random input element
#Variations:
# - "Fisher-Yates shuffle":
# - extract random input element, append to output, then repeat
# - "Durstenfeld shuffle":
# - extract random input element, append to output, then put last input element in its place, then repeat
# - "inside-out shuffle":
# - extract random input element, insert to output at random position, then repeat
# - swap random input element with another random input element among the following ones or itself, then repeat
# - "Sattolo cycle":
# - swap random input element with another random input element among the following ones excluding itself,
# then repeat
# - as opposed to others, will never shuffle to same result