n × n board is made of cells. Each cell is either empty (a space ' ') or crossed by a diagonal: '/' runs from the lower-left corner to the upper-right one, '\' from the upper-left corner to the lower-right one. The board is given as a list of strings tiles, where tiles[i][j] is the content of a cell.
The diagonals act as walls. Return how many connected regions they split the board into.
Note that a backslash is escaped in code, so the string "\\/" stands for the two cells \ and /.tiles=["/\\", " "] → 3
The / and \ in the top row form a roof: two top corners are cut off, and everything under the roof is the third region.
tiles=["\\/", "/\\"] → 4
The strokes form one big X across the whole board and split it into 4 triangles.
tiles=[" / ", "/ /", " / "] → 3
'/', '\' or ' 'tiles=["/\\", " "]
3
Run checks the first 3 tests in your browser. Submit checks all 23 tests on the server, hidden ones included.