I have created the following function to return all pairs (n, k)
such that a slightly altered binomial coefficient is less than or equal to a certain N
:
bin = lambda n, k : binomial(n + k - 1, k)
def nkfilter(N):
pairs = []
for n in range(2, N+1):
for k in range(1, n):
if bin(n, k) <= N:
pairs.append([n, k])
print '\n (n, k)\n'
return pairs
This prints out the following:
example = nkfilter(8); print example
(n, k)
[[2, 1], [3, 1], [3, 2], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1]]
I now would like to take this n
and generate a tuple of length n
: (a_1,..., a_n)
, for which all the a_i
s are less than or equal to k
. I have been considering permutations
to accomplish this, but I believe I need to first generate list_of_numbers_less_than_k
and then take permutations(n, list_of_numbers)
.
However I am not sure which data types to use, and how to generate these n
-length tuples.