Помощ със задача LineInventer.
Колкото и да се чудя как да го напиша не мога да измиясля някакъв начин, който да взима стойностите от матрицата и да ги обръща(от "W" на "B"). Ето какво успях да "сътворя" до момента: https://gist.github.com/anonymous/131dbaab752c19d1f861. Всъщност това просто запаметява стойностите в матрица (дори не мога да я принтирам като хората). От там не мога да измисля как би могла да се реши задачата. Ако някой има идеи ще се радвам даги чуя.
You’ll be given a board of size NxN where each cell is either white ('W') or black ('B'). On the first line you’ll be given the size N of the board and on each of the next N lines you’ll be given strings with N symbols (either 'W' or 'B') representing the colors of each cell of the respective row.
You are allowed to perform two operations – invert a row and invert a column. Inverting a row/column means switching the color of each cell on the row/column – from white to black and from black to white. The goal is to turn all cells on the board black. Print on the console the minimum number of inversions in order to turn the board black or -1 if this is impossible. Check out the examples for a visual explanation.
Input
The input data should be read from the console.
On the first line you’ll be given the size N of the board.
On the next N lines, you’ll be given strings with length N representing the colors of the cells of the respective row.
The input data will always be valid and in the format described. There is no need to check it explicitly.
Output
The output should be printed on the console. It should consist of only one line.
On the only output line print the minimum number of inversions needed in order to turn the board black or
-1 if it’s impossible.
Constraints
The size N of the board will be between 1 and 20.
The strings representing the rows will contain only the characters 'W' and 'B'.
Allowed working time for your program: 0.1 seconds. Allowed memory: 16 MB.