Created
July 29, 2015 02:29
-
-
Save hnq90/4cd1f05556a8a2e3aee9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_random(floor, ceiling): | |
| return random.randrange(floor, ceiling + 1) | |
| def naive_shuffle(the_array): | |
| # for each index in the array | |
| for first_index in xrange(0,len(the_array)-1): | |
| # grab a random other index | |
| second_index = get_random(0, len(the_array)-1) | |
| # and swap the values | |
| the_array[first_index], the_array[second_index] = the_array[second_index], the_array[first_index] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment