Skip to content

Instantly share code, notes, and snippets.

@attibalazs
Created March 29, 2016 14:57
Show Gist options
  • Save attibalazs/d51d333928a1565bfd9f to your computer and use it in GitHub Desktop.
Save attibalazs/d51d333928a1565bfd9f to your computer and use it in GitHub Desktop.
Lottery Simulator - it`s hard to win the lottery
import random
# example data
#generate random set
x = []
i = 1
while i < 10000000:
l = random.sample(range(1, 60), 6)
str1 = '-'.join(str(e) for e in l)
x.append(str1)
i += 1
#print x
#calculate frequency distribution
unique_values = set(x)
freq_distribution = {}
for i in unique_values:
freq_distribution[i] = 0
for i in x:
freq_distribution[i] += 1
#get distributions with frequency higher than 1
counter = 0
print "---------------------------"
print "Random Set - Frequency"
print "---------------------------"
for k, v in freq_distribution.iteritems(): # note use of iteritems()
if v > 1:
print " {0} - {1}".format(k, v)
counter += 1
print "total:", counter
print "-----"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment