Skip to content

Instantly share code, notes, and snippets.

@danibrear
Created October 5, 2013 04:12
Show Gist options
  • Save danibrear/6836598 to your computer and use it in GitHub Desktop.
Save danibrear/6836598 to your computer and use it in GitHub Desktop.
Python script to find the total number of options for a lottery with settings: ordered, unique ordered and unique
from itertools import product
if __name__ == '__main__':
selections = 10
blanks = 2
select_range = range(1, selections+1)
all_unique = 0
in_order = 0
total = 0
sorted_and_unique = 0
for x in product(select_range, repeat=blanks):
set_len = len(set(x))
len_x = len(x)
sort_x = sorted(x)
if len_x == set_len and x == tuple(sort_x):
sorted_and_unique += 1
all_unique += 1
in_order += 1
elif len_x == set_len:
all_unique += 1
elif x == tuple(sort_x):
in_order += 1
total += 1
print 'all_unique:',all_unique
print 'in_order:',in_order
print 'sorted_and_unique:',sorted_and_unique
print 'total:',total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment