Professional Documents
Culture Documents
House of Cards
House of Cards
House of Cards
There is a 5 X 5 matrix of cards. When you touch a card, it flips over and so does the cards on its either side and above and below too. If you touch a card on the vertex three cards flip over and if you touch a card on the edge then four cards flip over.
X X X
Your aim is to touch cards in the grid in such a way that the final result is all cards are face down. Touching a card twice will return the arrangement around it to the original state. If a particular solution is unsolvable, your program must return, unsolvable.
Input: A 5X5 grid of 1s and 0s. 1 indiactes face up and 0 indicates face down. Each element separated by a space. Output: A 5X5 grid with 1 at the places where you toch a card and 0 at places where you do not touch a card. Each element separated by a space.
Sample: Input: 01100 00101 11010 00011 00000 Output: 01100 11110 00100 01010 11100