title: Actions on a binary matrix
body: <p>The plan of the castle is given, which is represented as a binary matrix of the string type:
  Each binary code belongs to a specific cell. One cell has four sides, so we consider each side of the cell in the following order: left - up - right - down and set &quot;1&quot; if there is a wall, and &quot;0&quot; if there is no wall. You need to count the number of rooms in the castle, separated by walls (5 rooms in the picture).
  <a href="https://i.stack.imgur.com/Kohif.png" rel="nofollow noreferrer">enter image description here</a>
  <a href="https://i.stack.imgur.com/c4WyC.png" rel="nofollow noreferrer">enter image description here</a></p>