import random

def lottop(selected, nrepeat, nmatch):
###################################################################
# (C) 2022 Songyong Sim, Hallym Univ.
# This is to calculate empirical prob of Lottos
###################################################################
# INUPUT selected: selected set of 6 numbers
#         nrepeat: N of repetition
#         nmatch: number of matches out of 6 selected numbers
###################################################################
# OUTPUT: count: number of matches of nmatch
#         its corresponding prob
###################################################################
 count = 0
 for i in range(0, nrepeat):
   play = set( random.sample(range(1,46), 6) )
   match = [value for value in selected if value in play]
   if len(match) == nmatch:
      count += 1
 return(count, count/nrepeat)   

#------------------------------------------------------
selected1 = {1, 2, 10, 12, 34, 45}
n1, p1 = lottop(selected1, 1000000, 3)
print(n1, p1)

selected2 = set( random.sample(range(1,46), 6) )
print('randomly chosen set: ', selected2)
n1, p1 = lottop(selected2, 1000000, 3)
print(n1, p1)

n1, p1 = lottop(selected1, 10000000, 6)
print(n1, p1)



