Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import shuffle
- def shuffleAndMeet(population):
- shuffle(population)
- n = len(population)
- for t in range(n//2):
- population[t], population[t+n//2] = meet(population[t], population[t+n//2])
- def meet(x, y):
- if sorted(x+y) == sorted("si"):
- return "ss"
- elif "s" in x+y:
- return "rr"
- return x+y
- population = ["s"] + ["i" for t in range(99999)]
- print(population.count("i"), "\t", population.count("s"), "\t", population.count("r"))
- while (population.count("s")>0):
- shuffleAndMeet(population)
- print(population.count("i"), "\t", population.count("s"), "\t", population.count("r"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement