Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. from random import shuffle
  2.  
  3. def shuffleAndMeet(population):
  4. shuffle(population)
  5. n = len(population)
  6. for t in range(n//2):
  7. population[t], population[t+n//2] = meet(population[t], population[t+n//2])
  8.  
  9. def meet(x, y):
  10. if sorted(x+y) == sorted("si"):
  11. return "ss"
  12. elif "s" in x+y:
  13. return "rr"
  14. return x+y
  15.  
  16. population = ["s"] + ["i" for t in range(99999)]
  17. print(population.count("i"), "\t", population.count("s"), "\t", population.count("r"))
  18. while (population.count("s")>0):
  19. shuffleAndMeet(population)
  20. print(population.count("i"), "\t", population.count("s"), "\t", population.count("r"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement