Any better way to generate a tuple of all possible tuples in form of (x1,y1,x2,y2)?

Posted by zhanwu on Stack Overflow See other posts from Stack Overflow or by zhanwu
Published on 2010-04-19T08:58:16Z Indexed on 2010/04/19 9:03 UTC
Read the original article Hit count: 101

Filed under:

I want to generate a tuple of tuple in form of ((x1,y1,x2,y2),...(x1,y1,x2,y2)) where x1,y1,x2,y2 are all in range of (0,8).

Is there any other way rather than the following?

S = list()
for x1 in range(0, 8):
    for y1 in range(0, 8):
        for x2 in range(0, 8):
            for y2 in range(0, 8):
                S.append([x1,y1,x2,y2])
S = tuple(S)       

thanks

© Stack Overflow or respective owner

Related posts about python