How can I pick random indices of a matrix with a constraints?

I want to create a matrix like this one:

0000000000

0101110000

1111100000

0110100000

0010000000

0000000000

that is to say I want to randomly to pick indices for the second row to put 1's in a fixed number of cells, and I want that from the third row to put 1's in each cell but I have to allow a clear path of 1's from the third row to the second row (and it's also needs to be randomly - the pick of the indices in the third row) - any suggestions?

Re: How can I pick random indices of a matrix with a constraints?

I posted a reply in your other thread: http://www.java-forums.org/new-java/...reference.html, don't ignore replies.

kind regards,

Jos