[Numpy-discussion] lists of zeros and ones

gerardob gberbeglia at gmail.com
Fri Mar 19 10:53:56 EDT 2010

Hello, i would like to produce lists of lists 1's and 0's.

For example, to produce the list composed of:

L = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]

I just need to do the following:


I would like to know a simple way to generate a list containing all the
lists having two 1's at each element.

Example, n = 4
L2 = [[1,1,0,0],[1,0,1,0],[1,0,0,1],[0,1,1,0],[0,1,0,1],[0,0,1,1]]

Any ideas?

View this message in context: http://old.nabble.com/lists-of-zeros-and-ones-tp27950978p27950978.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.

More information about the NumPy-Discussion mailing list