# Crosscompute
items_text_path = './colors.txt'
k_int = 2
target_folder = './results'
from os.path import join
k, items = k_int, open(items_text_path, 'r').readlines()
target_path = join(target_folder, 'options.csv')
items = [x.strip() for x in items if x.strip()]
n = len(items)
from math import factorial
def binomial_coef(n, k):
num = factorial(n)
denom = factorial(k) * (factorial(n - k))
return int(num / denom)
sol = binomial_coef(n, k)
print('binomial_coefficient = %d' % sol)
from itertools import combinations
possible_choices = (combinations(items, k))
with open(target_path, 'w') as f:
for choice in possible_choices:
f.write(','.join(choice) + '\n')
print('choices_table_path = %s' % target_path)