A Shuffle of Eight


The Steps:

Build a array whoes elements are 2-arrays the first are the integers 0 through 7 and the second are all 0

[[0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0]]

Step 1: Pick a random random 2-array whose first element is between 1 and 7 ,say 4, and swap first elements with [0,0] ,using the second element of each 2-array as a marker by setting it to 1.

[[4,1],[1,0],[2,0],[3,0],[0,1],[5,0],[6,0],[7,0]]

Repeat by starting with the lowest 2-array entry with second element 0 and randomly choosing another 2-array with and second element 0.

[1,0] random choice [5,0]
        [[4,1],[5,1],[2,0],[3,0],[0,1],[1,1],[6,0],[7,0]]

[2,0] random choice [3,0]
        [[4,1],[5,1],[3,1],[2,1],[0,1],[1,1],[6,0],[7,0]]

[6,0] random choice [7,0]
        [[4,1],[5,1],[3,1],[2,1],[0,1],[1,1],[7,1],[6,1]]

The Permutation

[4,5,3,2,0,1,7,6]