Foxscotch

random list stuff

Nov 9th, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from random import randint, shuffle
  2. from time import sleep
  3.  
  4. # RETURNS a sorted list
  5. def rand_sort(inp):
  6.     l = list(inp)
  7.     cop = list(l)
  8.     cop.sort()
  9.     while l != cop:
  10.         shuffle(l)
  11.         print l
  12.     return l
  13.    
  14. # RETURNS a list of integers from 1 to the argument
  15. def gen_list(length):
  16.     l = []
  17.     full = False
  18.     while full == False:
  19.         r = randint(1,length)
  20.         if r not in l:
  21.             l.append(r)
  22.             if len(l) == length:
  23.                 full = True
  24.     l.sort()
  25.     return l
Advertisement
Add Comment
Please, Sign In to add comment