Available catch 999. car
On a 8 x 8 board, there is a white car (rook). It may also be available box, white elephant (bishop) and the black pawn (pawn). They are given to the character "R", ".", "B" and "p". The uppercase characters indicate White, Black lowercase characters are represented.
The car moves in chess rule: choose one of four basic directions (North, East, West and South), and then move in that direction until it choose to stop, or reach the edge of the board to move to the same square capture and death on the opposite color squares. In addition, the car can not be friendly with the other (white) like into the same box.
Returns the number of death in a car to be able to capture the move.
Example 1:
输入:[[".",".",".",".",".",".",".","."],[".",".",".",“p”,".",".",".","."],[".",".",".",“R”,".",".",".",“p”],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",“p”,".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",". "," "]]. Example 2:In the present embodiment, the vehicle can capture all died.Explanation:
Output: 3
输入:[[".",".",".",".",".",".",".","."],[".",“p”,“p”,“p”,“p”,“p”,".","."],[".",“p”,“p”,“B”,“p”,“p”,".","."],[".",“p”,“B”,“R”,“B”,“p”,".","."],[".",“p”,“p”,“B”,“p”,“p”,".","."],[".",“p”,“p”,“p”,“p”,“p”,".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]
输出:0
解释:
象阻止了车捕获任何卒。
示例 3:
输入:[[".",".",".",".",".",".",".","."],[".",".",".",“p”,".",".",".","."],[".",".",".",“p”,".",".",".","."],[“p”,“p”,".",“R”,".",“p”,“B”,"."],[".",".",".",".",".",".",".","."],[".",".",".",“B”,".",".",".","."],[".",".",".",“p”,".",".",".","."],[".",".",".",".",".",".",".","."]] car can capture position b5, d6 and f5 pawn.Explanation: The
Output: 3
prompt:
== Board board.length [I] .length. 8 ==
board [i] [j] may be 'R', '.', 'B' or 'p'
is only the presence of a board [i] on the lattice [j] == 'R'