Problem Statement | |||||||||||||
Chess is a game played on a square board of eight rows and eight columns of squares. Columns are marked 'a' to 'h' from left to right, and rows are numbered '1' to '8' from bottom to top. To play chess, you have to understand the paths by which pieces can attack. One of the pieces is a pawn. A pawn attacks diagonally, one square upward and to the left or right. For example, if a pawn is on c3, it threatens d4 and b4. You are given a String[] pawns, each element of which represents the position of a pawn on the board. Each element contains exactly 2 characters. The first character is the column ('a'-'h') and the second character is the row ('1'-'8'). Return the number of empty squares on the board that are threatened by pawns. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | pawns will contain between 1 and 20 elements, inclusive. | ||||||||||||
- | Each element in pawns will contain exactly 2 characters. | ||||||||||||
- | The first character in each element of pawns will be a lowercase letter between 'a' and 'h', inclusive. | ||||||||||||
- | The second character in each element of pawns will be a digit between '1' and '8', inclusive. | ||||||||||||
- | Each element in pawns will be unique. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|