0

I want to create a binary 16*15 matrix with certain conditions. I use binary strings to make the matrix. I want my matrix to be as described:

-The first and last two elements of each row must be alternative.

-the sum of each row must be 8 or 7.

-in each row, there should not be consecutive 1s or 0s. (one couple(00 or 11) is allowed in each row) .

-the sum of the columns must be 8.

there are 26 possible strings that can fulfill the first 3 conditions.how can I fulfill the last conditions? I have a code but it is not working because it takes so much time and it is almost impossible.is there any other way?

Sana.Nz
  • 81
  • 11

1 Answers1

1

I don't think you need any constraint to fulfill the last conditions. Columns = 8, which is just half of 16. You can just simply copy the first 8 rows to the last 8 rows and reverse all the 0 and 1, then the column sum would be 8 and the first three conditions are met.

wong.lok.yin
  • 849
  • 1
  • 5
  • 10
  • yes you are right. I tested it for all the even numbers between 0 to 20 and it worked! – Sana.Nz Jan 10 '20 at 15:26
  • but, I should add that I just copied first 8 and last 8. the sum of all the columns equaled to 8.no need to reverse – Sana.Nz Jan 10 '20 at 15:30