[Solved]Change the elements of a matrix so it becomes a matrix with just 0s | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[Solved]Change the elements of a matrix so it becomes a matrix with just 0s

Hi SoloLearn. I need some help with this problem: I have a binary matrix, let's say this one: 0 1 1 0 0 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 Every element has a "switch" that changes the element from 1 to 0 or viceversa, but it also changes the 2X2 square with that element as the right-bottom element. So the switch (i,j) changes: (i,j)(i-1,j)(i-1,j-1)(i,j-1). I can or cannot find a sequence that will turn all the elements in 0s. I have to say if there is or not any solution to this puzzle. Thanx! :)

8th Oct 2019, 3:30 PM
Stefan Secrieru
Stefan Secrieru - avatar
5 Answers
0
Assuming i is 0->4, top to bottom and j is 0->3, left to right 0110 0101 0011 0000 0000 switch (1, 2) 0[1][1]0 0[1]{0}1 0011 0000 0000 0000 0011 0011 0000 0000 switch (2, 3) 0000 00[1][1] 00[1]{1} 0000 0000 0000 0000 0000 0000 0000 There are multiple solutions
8th Oct 2019, 4:04 PM
jtrh
jtrh - avatar
0
jtrh Yes, there may be multiple solutions, but I must write a program that solves or not a random puzzle.
9th Oct 2019, 3:32 PM
Stefan Secrieru
Stefan Secrieru - avatar
0
*** That is allowed, but it will only change the lights that are in the matrix.
9th Oct 2019, 3:46 PM
Stefan Secrieru
Stefan Secrieru - avatar
0
I found a solution that I think uses Greedy, but I don't know if that will always work or not. I search for elements of 1 and when I find one, let's say (I,j), I switch (I+1,j+1)
9th Oct 2019, 3:49 PM
Stefan Secrieru
Stefan Secrieru - avatar
0
*** Thank you for your help, I think this solutions works. Have a great day:)
10th Oct 2019, 12:14 PM
Stefan Secrieru
Stefan Secrieru - avatar