comefrom: <doocs>0999.Available Captures for Rook_1.py
code: def numRookCaptures( board: List[List[str]]) -> int:
      x, y, n = 0, 0, 8
      for i in range(n):
          for j in range(n):
              if board[i][j] == 'R':
                  x, y = i, j
                  break
      ans = 0
      for a, b in [[0, -1], [0, 1], [-1, 0], [1, 0]]:
          i, j = x, y
          while 0 <= i + a < n and 0 <= j + b < n and board[i + a][j + b] != 'B':
              i, j = i + a, j + b
              if board[i][j] == 'p':
                  ans += 1
                  break
      return ans
masked: def sample_funcname ( var_0 : List [ List [ str ] ] ) -> int :
      var_1 , var_2 , var_3 = 0 , 0 , 8
      for var_4 in range ( var_3 ) :
          for var_5 in range ( var_3 ) :
              if var_0 [ var_4 ] [ var_5 ] == 'R' :
                  var_1 , var_2 = var_4 , var_5
                  break
      var_6 = 0
      for var_7 , var_8 in [ [ 0 , - 1 ] , [ 0 , 1 ] , [ - 1 , 0 ] , [ 1 , 0 ] ] :
          var_4 , var_5 = var_1 , var_2
          while 0 <= var_4 + var_7 < var_3 and 0 <= var_5 + var_8 < var_3 and var_0 [ var_4 + var_7 ] [ var_5 + var_8 ] != 'B' :
              var_4 , var_5 = var_4 + var_7 , var_5 + var_8
              if var_0 [ var_4 ] [ var_5 ] == 'p' :
                  var_6 += 1
                  break
      return var_6
  