Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- class Point :
- def __init__(self):
- self.unvisited = True
- def visit(self):
- self.unvisited = False
- class Visitor :
- def __init__(self):
- self.visited = []
- def goto(self, p):
- p.visit()
- self.visited += [p]
- #For einar theory
- k_distribution = [0 for _ in range(6)]
- case_number = 100000
- for case in range(case_number):
- #m = randint(1,100)
- #n = randint(1,100)
- m=6
- n=5
- points = []
- for point in range(m):
- points+=[Point()]
- visitors = []
- for visitor in range(n):
- visitors+=[Visitor()]
- k = 0
- while any([p.unvisited for p in points]):
- k+=1
- for visitor in visitors :
- next = points[randint(0,m-1)]
- while next in visitor.visited:
- next = points[randint(0,m-1)]
- visitor.goto(next)
- #print("{},{},{}".format(m,n,k))
- k_distribution[k-1]+=1
- print("Number of cases : {}".format(case_number))
- for i in range(6) :
- print("k={}, frequence={}".format(i+1,k_distribution[i]/case_number))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement