Skip to content

Instantly share code, notes, and snippets.

@CSaratakij
Created November 8, 2018 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CSaratakij/e7be0888ef2c377f9a3944e0126b78f6 to your computer and use it in GitHub Desktop.
Save CSaratakij/e7be0888ef2c377f9a3944e0126b78f6 to your computer and use it in GitHub Desktop.
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