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! :)
5 Respuestas
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
0
jtrh Yes, there may be multiple solutions, but I must write a program that solves or not a random puzzle.
0
*** That is allowed, but it will only change the lights that are in the matrix.
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)
0
*** Thank you for your help, I think this solutions works. Have a great day:)