Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is this what you want?

n=2
m=3
x = [f'x_{i+1}' for i in range(n)]
y = [f'y_{i+1}' for i in range(m)]

xy = [xi+yj for xi in x for yj in y]   # x first, then y

yx = [yj+xi for xi in x for yj in y]    # y first, then x

for t in Tuples((-1..1),len(xy)):
    r = ' '.join([('+' if s>0 else '-')+mon for s,mon in zip(t,xy) if s])
    print(r)

for t in Tuples((-1..1),len(yx)):
    r = ' '.join([('+' if s>0 else '-')+mon for s,mon in zip(t,yx) if s])
    print(r)