Skip to content

Instantly share code, notes, and snippets.

@JenkinsDev
Last active October 14, 2020 15:00

Revisions

  1. JenkinsDev revised this gist Oct 4, 2015. 2 changed files with 55 additions and 6 deletions.
    30 changes: 24 additions & 6 deletions fisher-yates-shuffle.py
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,26 @@
    from random import randint
    from random import randint, random
    from math import floor

    def fisher_yates_shuffle(the_list):
    list_range = range(0, len(the_list))
    for i in list_range:
    j = randint(list_range[0], list_range[-1])
    the_list[i], the_list[j] = the_list[j], the_list[i]
    return the_list
    list_range = range(0, len(the_list))
    for i in list_range:
    j = randint(list_range[0], list_range[-1])
    the_list[i], the_list[j] = the_list[j], the_list[i]
    return the_list

    def fisher_yates_shuffle_improved(the_list):
    amnt_to_shuffle = len(the_list)
    # We stop at 1 because anything * 0 is 0 and 0 is the first index in the list
    # so the final loop through would just cause the shuffle to place the first
    # element in... the first position, again. This causes this shuffling
    # algorithm to run O(n-1) instead of O(n).
    while amnt_to_shuffle > 1:
    # Indice must be an integer not a float and floor returns a float
    i = int(floor(random() * amnt_to_shuffle))
    # We are using the back of the list to store the already-shuffled-indice,
    # so we will subtract by one to make sure we don't overwrite/move
    # an already shuffled element.
    amnt_to_shuffle -= 1
    # Move item from i to the front-of-the-back-of-the-list. (Catching on?)
    the_list[i], the_list[amnt_to_shuffle] = the_list[amnt_to_shuffle], the_list[i]
    return the_list
    31 changes: 31 additions & 0 deletions improved-shuffling-step-by-step.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    Running the fisher_yates_shuffle_improved() function caused a decently significant increase in speed by making the algorithm now run
    O(n-1) times. This 'improved' algorithm also now makes sure that you can't shuffle an element that you have already shuffled because
    we use the back of the list to store the previously shuffled elements.

    Here is the outcome of each loop on a test run:

    ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'z', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'n']
    ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'z', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'y', 'x', 'n']
    ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'z', 'o', 'y', 'q', 'r', 's', 't', 'u', 'v', 'w', 'p', 'x', 'n']
    ['a', 'b', 'c', 'd', 'e', 'w', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'z', 'o', 'y', 'q', 'r', 's', 't', 'u', 'v', 'f', 'p', 'x', 'n']
    ['a', 'b', 'c', 'd', 'e', 'w', 'v', 'h', 'i', 'j', 'k', 'l', 'm', 'z', 'o', 'y', 'q', 'r', 's', 't', 'u', 'g', 'f', 'p', 'x', 'n']
    ['a', 'b', 'c', 'd', 'e', 'w', 'v', 'h', 'i', 'j', 'k', 'l', 'm', 'z', 'o', 'y', 'q', 'r', 's', 't', 'u', 'g', 'f', 'p', 'x', 'n']
    ['t', 'b', 'c', 'd', 'e', 'w', 'v', 'h', 'i', 'j', 'k', 'l', 'm', 'z', 'o', 'y', 'q', 'r', 's', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['t', 'b', 'c', 'd', 'e', 'w', 's', 'h', 'i', 'j', 'k', 'l', 'm', 'z', 'o', 'y', 'q', 'r', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['t', 'b', 'c', 'd', 'e', 'w', 's', 'h', 'i', 'j', 'k', 'l', 'm', 'z', 'r', 'y', 'q', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['q', 'b', 'c', 'd', 'e', 'w', 's', 'h', 'i', 'j', 'k', 'l', 'm', 'z', 'r', 'y', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['q', 'b', 'c', 'd', 'e', 'y', 's', 'h', 'i', 'j', 'k', 'l', 'm', 'z', 'r', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['q', 'b', 'c', 'd', 'e', 'y', 's', 'h', 'i', 'r', 'k', 'l', 'm', 'z', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['q', 'b', 'c', 'd', 'e', 'y', 's', 'h', 'i', 'r', 'k', 'l', 'z', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['z', 'b', 'c', 'd', 'e', 'y', 's', 'h', 'i', 'r', 'k', 'l', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['z', 'b', 'c', 'd', 'e', 'y', 's', 'h', 'i', 'l', 'k', 'r', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['z', 'b', 'c', 'd', 'k', 'y', 's', 'h', 'i', 'l', 'e', 'r', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['z', 'b', 'c', 'd', 'k', 'y', 's', 'h', 'i', 'l', 'e', 'r', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['z', 'b', 'c', 'd', 'k', 'y', 'i', 'h', 's', 'l', 'e', 'r', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['z', 'b', 'h', 'd', 'k', 'y', 'i', 'c', 's', 'l', 'e', 'r', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['z', 'b', 'h', 'd', 'k', 'y', 'i', 'c', 's', 'l', 'e', 'r', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['z', 'y', 'h', 'd', 'k', 'b', 'i', 'c', 's', 'l', 'e', 'r', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['k', 'y', 'h', 'd', 'z', 'b', 'i', 'c', 's', 'l', 'e', 'r', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['k', 'y', 'd', 'h', 'z', 'b', 'i', 'c', 's', 'l', 'e', 'r', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['k', 'y', 'd', 'h', 'z', 'b', 'i', 'c', 's', 'l', 'e', 'r', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
    ['y', 'k', 'd', 'h', 'z', 'b', 'i', 'c', 's', 'l', 'e', 'r', 'q', 'm', 'j', 'w', 't', 'o', 'v', 'a', 'u', 'g', 'f', 'p', 'x', 'n']
  2. JenkinsDev revised this gist Oct 4, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion fisher-yates-shuffle.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    from random import randint


    def fisher_yates_shuffle(the_list):
    list_range = range(0, len(the_list))
    for i in list_range:
  3. JenkinsDev revised this gist Oct 4, 2015. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion outcome.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    Running a list of the alphabet (the_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) through the shuffle algorithm 100 times produced the following results:
    Running a list of the alphabet (the_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'])
    through the shuffle algorithm 100 times produced the following results:

    ['j', 'z', 'i', 'x', 'o', 'y', 'h', 'a', 'd', 'p', 'f', 'q', 'b', 'r', 'k', 'n', 't', 'w', 'v', 'e', 's', 'u', 'c', 'g', 'm', 'l']
    ['d', 'a', 'n', 'u', 'i', 'z', 'j', 'm', 'x', 'e', 't', 'g', 'y', 'r', 'f', 'q', 'o', 'v', 'p', 'b', 'w', 'k', 'c', 'h', 's', 'l']
  4. JenkinsDev revised this gist Oct 4, 2015. No changes.
  5. JenkinsDev created this gist Oct 4, 2015.
    9 changes: 9 additions & 0 deletions fisher-yates-shuffle.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    from random import randint


    def fisher_yates_shuffle(the_list):
    list_range = range(0, len(the_list))
    for i in list_range:
    j = randint(list_range[0], list_range[-1])
    the_list[i], the_list[j] = the_list[j], the_list[i]
    return the_list
    102 changes: 102 additions & 0 deletions outcome.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,102 @@
    Running a list of the alphabet (the_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) through the shuffle algorithm 100 times produced the following results:

    ['j', 'z', 'i', 'x', 'o', 'y', 'h', 'a', 'd', 'p', 'f', 'q', 'b', 'r', 'k', 'n', 't', 'w', 'v', 'e', 's', 'u', 'c', 'g', 'm', 'l']
    ['d', 'a', 'n', 'u', 'i', 'z', 'j', 'm', 'x', 'e', 't', 'g', 'y', 'r', 'f', 'q', 'o', 'v', 'p', 'b', 'w', 'k', 'c', 'h', 's', 'l']
    ['d', 'l', 'e', 'v', 'p', 'y', 'n', 't', 'i', 'm', 'u', 's', 'z', 'q', 'h', 'o', 'w', 'k', 'f', 'r', 'a', 'c', 'x', 'b', 'g', 'j']
    ['t', 'b', 'x', 'f', 'j', 'i', 'd', 'c', 'w', 'q', 'p', 'h', 'v', 'k', 'r', 'g', 's', 'z', 'n', 'o', 'm', 'e', 'u', 'a', 'l', 'y']
    ['b', 'v', 'm', 'w', 'a', 'h', 't', 'c', 'k', 'y', 'j', 'o', 'p', 'u', 's', 'r', 'i', 'n', 'x', 'e', 'd', 'z', 'q', 'g', 'l', 'f']
    ['b', 'w', 'p', 'j', 'h', 'm', 'c', 'v', 'z', 't', 'g', 'q', 'u', 's', 'e', 'l', 'i', 'r', 'd', 'o', 'x', 'n', 'k', 'y', 'f', 'a']
    ['e', 'u', 'i', 'k', 'h', 'n', 'w', 'v', 'f', 'o', 'm', 'z', 'j', 'd', 's', 'r', 'p', 'q', 'x', 'a', 'l', 't', 'c', 'y', 'g', 'b']
    ['t', 'p', 'y', 'm', 'i', 'c', 'l', 's', 'n', 'v', 'a', 'f', 'u', 'r', 'j', 'd', 'q', 'w', 'x', 'e', 'o', 'h', 'g', 'b', 'k', 'z']
    ['x', 's', 'y', 't', 'd', 'o', 'n', 'l', 'c', 'r', 'p', 'u', 'z', 'k', 'b', 'f', 'i', 'g', 'w', 'a', 'q', 'j', 'e', 'v', 'h', 'm']
    ['r', 'j', 'u', 'l', 'h', 'm', 'e', 'k', 'w', 'f', 'q', 'o', 'n', 's', 't', 'x', 'g', 'p', 'i', 'v', 'a', 'b', 'z', 'c', 'd', 'y']
    ['f', 'm', 'k', 'x', 'y', 'o', 'p', 't', 's', 'z', 'i', 'v', 'g', 'n', 'j', 'u', 'c', 'd', 'q', 'r', 'w', 'a', 'h', 'e', 'b', 'l']
    ['n', 'g', 'j', 'q', 'f', 't', 'y', 'd', 'i', 'h', 'k', 'v', 'l', 'c', 'z', 'x', 'a', 'm', 'b', 'r', 'o', 'w', 'e', 'u', 's', 'p']
    ['w', 'i', 'r', 'x', 's', 'd', 'z', 'a', 'e', 'h', 'o', 'm', 'f', 'u', 'q', 'c', 'k', 'g', 'v', 'j', 'n', 't', 'b', 'p', 'l', 'y']
    ['r', 'u', 's', 'd', 'f', 'v', 'w', 'y', 'n', 'o', 'c', 'p', 'g', 'j', 'b', 'm', 'z', 'h', 'l', 'k', 'q', 'i', 'x', 't', 'e', 'a']
    ['h', 'n', 'j', 'v', 'o', 'z', 'c', 'k', 'x', 'u', 'p', 'b', 'f', 's', 'i', 'e', 'w', 'd', 'g', 'm', 'r', 'a', 't', 'y', 'q', 'l']
    ['i', 'x', 'e', 'b', 'z', 'q', 'g', 't', 'v', 'o', 'd', 'h', 'n', 'k', 'm', 'a', 'f', 'r', 'y', 'w', 'u', 'p', 'j', 's', 'c', 'l']
    ['z', 'b', 'v', 'q', 'f', 'r', 'w', 'h', 'e', 'i', 'j', 'u', 'k', 'g', 'a', 'c', 'o', 'l', 's', 'm', 't', 'x', 'd', 'y', 'n', 'p']
    ['s', 'a', 'e', 'h', 'k', 'i', 'l', 'y', 'o', 'q', 'p', 'f', 'r', 'b', 'j', 'x', 'g', 'w', 'c', 'd', 'n', 'v', 'm', 't', 'u', 'z']
    ['q', 't', 'p', 'f', 'w', 'm', 'i', 'h', 'g', 'l', 'x', 'c', 'y', 'd', 'n', 'j', 'a', 'e', 'b', 'z', 'o', 'v', 'k', 's', 'u', 'r']
    ['o', 'c', 't', 'h', 'm', 'w', 'd', 'v', 'j', 'z', 's', 'k', 'e', 'b', 'f', 'n', 'r', 'l', 'q', 'g', 'i', 'x', 'y', 'p', 'a', 'u']
    ['j', 'f', 'e', 'y', 'h', 'u', 'k', 'c', 't', 'i', 'n', 'p', 'b', 's', 'q', 'd', 'r', 'z', 'w', 'o', 'x', 'g', 'v', 'a', 'l', 'm']
    ['z', 't', 'e', 'g', 'j', 'c', 'q', 'o', 'f', 's', 'l', 'b', 'm', 'r', 'v', 'p', 'k', 'a', 'x', 'n', 'i', 'w', 'd', 'y', 'h', 'u']
    ['q', 'h', 'o', 'k', 'n', 'g', 'a', 'j', 'd', 'r', 'm', 'y', 'l', 'f', 'p', 'v', 'i', 'u', 'b', 'z', 'w', 'c', 'e', 't', 'x', 's']
    ['n', 'j', 'h', 'x', 'p', 'w', 'b', 'l', 'k', 'o', 'y', 'e', 'g', 'i', 'u', 's', 'q', 'v', 'd', 'z', 'c', 't', 'a', 'f', 'r', 'm']
    ['q', 'k', 'y', 'r', 'b', 'l', 'g', 'e', 'o', 'u', 'h', 't', 'a', 'm', 'c', 'd', 'f', 's', 'v', 'x', 'j', 'z', 'w', 'i', 'p', 'n']
    ['v', 'e', 'd', 'j', 'k', 'o', 'g', 'h', 'x', 'z', 'q', 'a', 'c', 't', 'p', 'u', 'w', 'n', 'i', 'r', 'm', 'b', 'l', 'y', 's', 'f']
    ['b', 'o', 'c', 'f', 'v', 'n', 'p', 'x', 'h', 't', 'y', 'z', 's', 'g', 'e', 'i', 'm', 'j', 'd', 'w', 'k', 'a', 'l', 'r', 'q', 'u']
    ['o', 'e', 'a', 'k', 'v', 'x', 'z', 'q', 'm', 'i', 'r', 'y', 'j', 'g', 's', 'l', 'c', 'p', 'n', 'u', 'd', 'h', 't', 'b', 'w', 'f']
    ['g', 't', 'l', 'x', 'u', 's', 'a', 'y', 'f', 'r', 'v', 'k', 'b', 'n', 'p', 'w', 'd', 'z', 'c', 'h', 'q', 'e', 'o', 'm', 'j', 'i']
    ['t', 'y', 'm', 'x', 'p', 'h', 'i', 'b', 'c', 'd', 'e', 'r', 'v', 'o', 'l', 'n', 'z', 'w', 'g', 'k', 's', 'q', 'f', 'a', 'u', 'j']
    ['e', 'n', 'x', 'p', 'l', 'q', 't', 'o', 'b', 'g', 'a', 'h', 'k', 'm', 'i', 'f', 'y', 'c', 'z', 'd', 'w', 'v', 'u', 's', 'j', 'r']
    ['o', 'r', 'p', 'j', 'c', 'n', 'w', 'z', 't', 'b', 'q', 'a', 'y', 'v', 'm', 'e', 'd', 'f', 'h', 'i', 'g', 'u', 'x', 'l', 'k', 's']
    ['t', 'j', 'e', 'p', 'w', 'x', 'a', 'd', 'i', 's', 'f', 'h', 'u', 'b', 'l', 'v', 'o', 'g', 'n', 'y', 'r', 'c', 'k', 'm', 'z', 'q']
    ['h', 's', 'z', 'b', 'v', 'd', 'y', 'i', 'n', 'l', 'm', 'f', 'r', 'g', 'q', 'u', 'x', 'w', 'c', 'j', 'k', 'p', 'o', 'e', 'a', 't']
    ['a', 'j', 'w', 'r', 'h', 'm', 'x', 'z', 'g', 'i', 'd', 'u', 'o', 'e', 'c', 'l', 'q', 'p', 'v', 's', 'f', 'y', 'n', 't', 'b', 'k']
    ['z', 'l', 'o', 'q', 'r', 'x', 'c', 'h', 'k', 'u', 'i', 'a', 'y', 'b', 's', 'm', 'f', 'j', 't', 'g', 'e', 'n', 'w', 'd', 'p', 'v']
    ['r', 'f', 'w', 'y', 's', 'o', 'l', 'b', 'j', 'm', 'a', 'c', 'z', 'q', 'g', 'n', 'd', 'p', 'v', 'e', 'x', 'u', 'k', 't', 'h', 'i']
    ['b', 'p', 'm', 'c', 's', 'o', 'z', 'y', 'a', 'v', 'q', 'l', 'j', 'd', 'n', 'u', 'i', 'f', 'x', 'e', 'k', 'g', 'w', 't', 'h', 'r']
    ['y', 'c', 'i', 'f', 'a', 'q', 'v', 'e', 's', 'j', 'n', 'x', 'z', 'p', 'o', 'h', 'b', 'g', 'u', 'r', 'w', 'd', 't', 'k', 'm', 'l']
    ['j', 'w', 'd', 'n', 'o', 'x', 'a', 'z', 'c', 'y', 'b', 's', 'p', 't', 'k', 'e', 'u', 'm', 'i', 'f', 'r', 'g', 'q', 'h', 'l', 'v']
    ['w', 'y', 'l', 'c', 'u', 'z', 't', 'q', 'm', 'b', 'r', 'o', 'h', 'k', 'd', 'e', 'j', 'v', 'a', 'f', 'n', 'g', 's', 'i', 'p', 'x']
    ['e', 't', 's', 'z', 'r', 'b', 'u', 'j', 'n', 'v', 'd', 'h', 'i', 'a', 'm', 'f', 'o', 'l', 'q', 'c', 'g', 'k', 'x', 'p', 'w', 'y']
    ['h', 'b', 'u', 's', 'r', 'j', 'y', 'o', 'n', 'a', 'd', 'm', 'p', 'f', 'x', 'w', 'e', 'z', 'q', 't', 'v', 'c', 'i', 'g', 'k', 'l']
    ['a', 'p', 'g', 'f', 't', 'z', 'k', 'c', 'j', 'b', 'l', 'm', 'n', 'w', 'y', 'u', 'h', 'v', 'q', 'i', 's', 'o', 'd', 'e', 'x', 'r']
    ['a', 'y', 'n', 'z', 'l', 'f', 'e', 'g', 'j', 'c', 'h', 'w', 'v', 'q', 'r', 'b', 'i', 'k', 'u', 'x', 'm', 'o', 't', 'd', 's', 'p']
    ['a', 'w', 'y', 'n', 'f', 'p', 'z', 'b', 'l', 'm', 'v', 't', 'r', 's', 'x', 'j', 'h', 'd', 'g', 'o', 'k', 'e', 'q', 'u', 'i', 'c']
    ['y', 'l', 'd', 'g', 't', 'u', 'k', 'm', 'b', 'v', 'r', 'p', 'x', 'n', 'o', 'j', 'h', 'q', 'w', 'f', 'c', 'e', 's', 'i', 'z', 'a']
    ['p', 'f', 'g', 'm', 'j', 'e', 'w', 'l', 'q', 'i', 'o', 'h', 'y', 'n', 'd', 'c', 'u', 's', 'b', 'v', 'a', 'r', 'z', 't', 'x', 'k']
    ['b', 'x', 'g', 'y', 'l', 't', 'v', 'r', 'o', 'h', 's', 'i', 'd', 'j', 'f', 'u', 'z', 'n', 'a', 'm', 'c', 'q', 'e', 'k', 'w', 'p']
    ['c', 'k', 'b', 'n', 'e', 'q', 'h', 'u', 'l', 'i', 'j', 'a', 'w', 'x', 's', 'p', 'o', 'f', 'm', 'v', 'y', 't', 'd', 'z', 'r', 'g']
    ['j', 'k', 'g', 'd', 'o', 'c', 'w', 'i', 'a', 'u', 'l', 's', 'q', 'e', 'y', 'x', 't', 'h', 'z', 'v', 'r', 'm', 'n', 'p', 'f', 'b']
    ['r', 'e', 'p', 'b', 'q', 'v', 's', 'n', 'l', 'o', 'u', 'z', 'a', 'x', 'g', 'h', 'w', 'c', 'd', 'i', 'm', 'y', 'k', 'f', 'j', 't']
    ['p', 'a', 'n', 'w', 't', 'x', 'z', 'u', 'q', 'b', 'o', 'y', 'm', 'd', 'j', 's', 'i', 'k', 'v', 'l', 'r', 'f', 'c', 'g', 'e', 'h']
    ['b', 'v', 's', 't', 'a', 'g', 'd', 'i', 'e', 'u', 'p', 'x', 'f', 'k', 'c', 'z', 'm', 'y', 'r', 'l', 'h', 'q', 'n', 'o', 'j', 'w']
    ['j', 'a', 'i', 'e', 's', 'b', 'u', 'h', 'z', 'q', 'n', 'r', 'd', 't', 'y', 'l', 'g', 'k', 'm', 'x', 'c', 'o', 'p', 'f', 'w', 'v']
    ['n', 't', 'h', 's', 'q', 'u', 'a', 'i', 'y', 'r', 'd', 'p', 'b', 'z', 'x', 'e', 'c', 'l', 'f', 'j', 'v', 'm', 'g', 'o', 'k', 'w']
    ['a', 'x', 'u', 'w', 'i', 'c', 'e', 'p', 's', 'n', 'l', 'k', 'g', 'y', 'j', 'f', 'b', 'z', 'v', 'o', 'd', 'r', 'q', 'h', 'm', 't']
    ['d', 'l', 's', 'p', 'u', 'm', 'r', 'x', 'w', 'y', 'h', 'o', 'c', 'v', 'g', 'b', 'e', 'f', 'a', 'i', 'n', 't', 'k', 'j', 'z', 'q']
    ['t', 'v', 'l', 'w', 'r', 'z', 'h', 'x', 'a', 'o', 'd', 'j', 'b', 'g', 'p', 'k', 'u', 'i', 'f', 'm', 's', 'e', 'n', 'c', 'q', 'y']
    ['b', 'j', 'c', 'g', 'z', 'r', 'm', 'i', 'd', 'n', 'l', 'y', 'v', 'p', 'k', 'u', 'q', 't', 'a', 'x', 'e', 's', 'o', 'f', 'h', 'w']
    ['t', 'p', 'r', 'u', 'w', 'k', 'q', 'o', 'm', 'c', 'b', 'h', 'j', 'd', 'n', 'l', 'f', 'v', 'a', 'x', 's', 'z', 'g', 'i', 'y', 'e']
    ['p', 's', 'b', 't', 'c', 'e', 'j', 'q', 'v', 'y', 'k', 'g', 'i', 'x', 'l', 'n', 'f', 'o', 'a', 'r', 'z', 'd', 'u', 'm', 'w', 'h']
    ['s', 'j', 't', 'r', 'k', 'l', 'w', 'q', 'c', 'x', 'u', 'p', 'n', 'f', 'g', 'b', 'h', 'a', 'z', 'v', 'm', 'e', 'o', 'd', 'i', 'y']
    ['a', 'b', 'n', 'k', 'e', 'y', 'x', 'h', 't', 'u', 'i', 'v', 'f', 'o', 'w', 'j', 'd', 'z', 'l', 'r', 'q', 'g', 'c', 's', 'p', 'm']
    ['j', 'l', 'q', 'a', 'd', 't', 'h', 'b', 'u', 'i', 'p', 'o', 'n', 'g', 'm', 'f', 'k', 'z', 'v', 'y', 'x', 's', 'w', 'e', 'r', 'c']
    ['d', 'p', 't', 'n', 'h', 'w', 'g', 's', 'o', 'k', 'l', 'v', 'c', 'b', 'e', 'x', 'q', 'm', 'j', 'z', 'i', 'f', 'u', 'r', 'a', 'y']
    ['e', 'u', 'l', 'r', 't', 'd', 'c', 'q', 'p', 'j', 'v', 'b', 'z', 'f', 'a', 's', 'g', 'h', 'y', 'o', 'n', 'w', 'k', 'x', 'm', 'i']
    ['o', 'k', 't', 'j', 'd', 'n', 'a', 'r', 'm', 'p', 'f', 'y', 'x', 'c', 'g', 'b', 'u', 's', 'z', 'h', 'v', 'q', 'i', 'w', 'l', 'e']
    ['w', 'd', 'c', 's', 'g', 'n', 'm', 'r', 'p', 'a', 'y', 't', 'j', 'l', 'o', 'b', 'x', 'v', 'f', 'e', 'k', 'h', 'z', 'i', 'q', 'u']
    ['x', 'o', 'g', 'w', 'q', 'n', 'm', 'h', 'r', 'c', 'e', 'l', 'u', 'i', 'f', 's', 'v', 'b', 't', 'j', 'a', 'z', 'p', 'k', 'y', 'd']
    ['l', 'q', 'y', 'r', 'v', 'p', 'f', 'm', 'g', 'i', 'k', 'h', 'z', 'j', 'o', 'x', 'e', 't', 's', 'a', 'u', 'w', 'b', 'n', 'd', 'c']
    ['w', 'j', 'd', 'i', 'b', 'l', 'u', 'a', 'p', 'x', 'q', 'm', 'h', 't', 'g', 'r', 's', 'z', 'n', 'c', 'o', 'k', 'y', 'e', 'f', 'v']
    ['a', 'n', 'f', 'r', 'u', 'l', 'i', 'd', 'e', 'p', 'g', 'x', 'w', 'h', 'm', 'v', 'o', 'k', 's', 'c', 't', 'z', 'j', 'y', 'b', 'q']
    ['n', 'm', 'i', 'r', 'h', 's', 'y', 'f', 'l', 'c', 'o', 'a', 'v', 't', 'q', 'p', 'g', 'z', 'j', 'b', 'd', 'x', 'w', 'e', 'k', 'u']
    ['y', 'j', 'i', 'f', 'l', 'x', 's', 'z', 'h', 'v', 't', 'w', 'o', 'a', 'c', 'q', 'b', 'r', 'p', 'e', 'g', 'k', 'd', 'm', 'u', 'n']
    ['j', 'v', 'r', 'u', 'z', 'd', 'x', 'm', 'a', 'w', 'f', 'h', 't', 'c', 'q', 'g', 'e', 'y', 'o', 'i', 'l', 'n', 'b', 's', 'k', 'p']
    ['m', 'v', 'y', 'q', 'u', 'o', 'g', 'r', 'i', 'k', 'n', 'x', 's', 'a', 'e', 'c', 'b', 'h', 't', 'd', 'z', 'l', 'w', 'p', 'j', 'f']
    ['m', 'd', 'v', 'e', 'w', 's', 'h', 'a', 'x', 'k', 'z', 'q', 'i', 't', 'j', 'u', 'y', 'b', 'l', 'c', 'o', 'r', 'p', 'n', 'f', 'g']
    ['t', 'n', 'h', 'f', 'v', 'y', 'o', 'c', 'p', 'z', 's', 'j', 'g', 'l', 'a', 'x', 'w', 'd', 'u', 'i', 'k', 'e', 'r', 'q', 'm', 'b']
    ['c', 's', 'h', 'k', 'p', 'b', 'i', 'z', 'u', 'w', 'q', 'r', 't', 'y', 'o', 'x', 'j', 'l', 'm', 'f', 'n', 'a', 'd', 'g', 'e', 'v']
    ['r', 'u', 'h', 't', 'g', 'f', 'a', 'j', 'b', 'm', 'e', 'w', 'z', 'p', 'i', 'x', 'v', 'k', 'd', 'c', 'y', 'n', 's', 'q', 'o', 'l']
    ['e', 'k', 'y', 'a', 'r', 's', 'b', 'w', 't', 'q', 'z', 'h', 'g', 'd', 'm', 'x', 'o', 'f', 'c', 'v', 'l', 'n', 'p', 'i', 'j', 'u']
    ['a', 'c', 'y', 'z', 'm', 'n', 't', 'q', 'o', 'j', 'k', 's', 'w', 'i', 'h', 'v', 'u', 'd', 'x', 'p', 'l', 'f', 'g', 'r', 'b', 'e']
    ['o', 'm', 'l', 'e', 'n', 'z', 's', 'k', 'b', 'y', 'h', 'd', 'u', 'x', 'q', 'a', 'g', 'c', 'f', 'r', 'w', 'v', 'p', 't', 'j', 'i']
    ['x', 'k', 'c', 't', 'j', 'o', 'z', 'v', 'p', 'f', 'w', 'r', 'l', 'm', 'e', 'n', 's', 'i', 'g', 'q', 'h', 'u', 'a', 'd', 'y', 'b']
    ['g', 'a', 'e', 'z', 'm', 'j', 'o', 'i', 'n', 'w', 'd', 'v', 'b', 'p', 'k', 'l', 'c', 'u', 'q', 'x', 't', 'y', 's', 'f', 'h', 'r']
    ['i', 's', 'q', 'j', 'c', 'e', 'm', 'w', 'b', 'n', 'v', 'l', 'a', 'h', 'z', 'o', 'y', 'p', 'r', 'k', 't', 'f', 'g', 'x', 'd', 'u']
    ['z', 'm', 'v', 'o', 'x', 'l', 'q', 't', 'a', 'c', 'r', 'j', 'y', 'g', 'n', 'p', 'f', 's', 'k', 'w', 'b', 'd', 'i', 'u', 'e', 'h']
    ['e', 's', 'd', 'w', 'b', 'j', 'q', 'h', 'x', 'l', 'm', 't', 'z', 'k', 'o', 'f', 'a', 'c', 'i', 'p', 'n', 'v', 'y', 'r', 'u', 'g']
    ['z', 'e', 'x', 's', 'j', 'n', 'd', 'p', 'y', 'h', 'b', 'v', 't', 'u', 'a', 'f', 'm', 'q', 'c', 'i', 'o', 'k', 'g', 'l', 'w', 'r']
    ['m', 'd', 'h', 'w', 'z', 'x', 'r', 'u', 'i', 't', 'f', 'q', 'l', 'e', 'b', 'v', 'c', 'k', 'y', 'a', 's', 'j', 'n', 'p', 'o', 'g']
    ['c', 'a', 'l', 'b', 'k', 'z', 'x', 'h', 'y', 'v', 's', 'p', 'q', 'r', 'i', 'm', 'w', 'd', 'f', 't', 'n', 'g', 'e', 'o', 'j', 'u']
    ['f', 'o', 'x', 'k', 'z', 'v', 't', 'w', 'e', 'g', 'i', 'p', 'b', 's', 'n', 'y', 'u', 'h', 'q', 'd', 'a', 'l', 'c', 'j', 'r', 'm']
    ['g', 'q', 'i', 'e', 't', 'y', 'b', 's', 'x', 'k', 'v', 'h', 'd', 'f', 'c', 'm', 'o', 'w', 'p', 'l', 'j', 'a', 'u', 'z', 'n', 'r']
    ['y', 'o', 'h', 'm', 'k', 'r', 'f', 'a', 'j', 'e', 'd', 'c', 'g', 'w', 'u', 'l', 'n', 'b', 'x', 't', 's', 'p', 'z', 'q', 'v', 'i']
    ['y', 't', 'z', 'r', 'e', 'j', 'v', 'o', 'd', 'k', 'g', 'f', 'n', 'l', 'b', 'x', 'w', 'a', 'i', 'q', 's', 'm', 'u', 'p', 'c', 'h']
    ['y', 'x', 'a', 'l', 'k', 'j', 'c', 'w', 'z', 'i', 'n', 'v', 'b', 'q', 'g', 'r', 'h', 'e', 'm', 's', 'p', 'f', 'o', 'u', 't', 'd']
    ['u', 'd', 'p', 'w', 'g', 'v', 'l', 'j', 's', 'i', 'y', 'h', 'k', 'z', 'r', 'e', 'f', 'm', 'o', 'q', 'b', 'a', 'n', 't', 'x', 'c']
    ['i', 'z', 'k', 'l', 'y', 'x', 't', 'j', 'g', 'a', 's', 'h', 'm', 'f', 'r', 'p', 'v', 'c', 'o', 'd', 'u', 'b', 'n', 'w', 'q', 'e']
    ['c', 'r', 'l', 'x', 't', 'o', 'w', 'p', 's', 'h', 'u', 'e', 'n', 'a', 'k', 'j', 'q', 'y', 'v', 'm', 'z', 'i', 'f', 'g', 'd', 'b']