Guest User

Untitled

a guest
Feb 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import random
  2.  
  3. def comparator(x,y):
  4. counter = 1
  5. while set(x) != set(y):
  6. y = random.sample(range(1,46),4)
  7. if set(x) == set(y):
  8. print x,y
  9. return counter
  10. else:
  11. counter +=1
  12.  
  13.  
  14. #call the function 5 times
  15. for i in range(1,6):
  16. selection = random.sample(range(1,46),4)
  17. draw = []
  18. output = comparator(selection,draw)
  19. print "Iteration %d = %d attempts" %(i,output)
Add Comment
Please, Sign In to add comment