Created
November 8, 2018 19:32
-
-
Save CSaratakij/e7be0888ef2c377f9a3944e0126b78f6 to your computer and use it in GitHub Desktop.
This file contains 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
import random | |
def main(): | |
random.seed() | |
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
print("Before shuffle : " + str(numbers)) | |
numbers = shuffle(numbers) | |
print("After shuffle : " + str(numbers)) | |
def shuffle(list): | |
maxIndex = len(list) - 1 | |
while (maxIndex > 0): | |
pickIndex = random.randint(0, maxIndex) | |
list[pickIndex], list[maxIndex] = list[maxIndex], list[pickIndex] | |
maxIndex -= 1 | |
return list | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment