I am trying to make a python program that produces all combinations of an n-1
number with a length L
:
I've tried using the itertools
but to not avail. I am trying to make it so that it produces the output above when I give it the arguments 5 3
in my terminal. I am using python3. An explanation would be great. Here is my code.
import sys
import itertools
def comb(A,n,k,p,lo):
stuff = [A, n, k,p,lo]
return itertools.combinations(stuff, len(stuff)
if __name__ == "__main__":
d = len(sys.argv)>3
n = int(sys.argv[1])
k = int(sys.argv[2])
A = []
for i in range(k):
A.append(0)
if d: print("n:",n,"k:",k)
comb(A,n,k,0,0)