Problem Statement
You are given
Definition
- Class:
- KingsTour
- Method:
- attackPawns
- Parameters:
- String, String, String
- Returns:
- int
- Method signature:
- int attackPawns(String king, String pawnA, String pawnB)
- (be sure your method is public)
Constraints
- king, pawnA and pawnB will each contain exactly 2 characters.
- The first character in king, pawnA and pawnB will each be a lowercase letter between 'a' and 'h', inclusive.
- The second character in king, pawnA and pawnB will each be a digit between '1' and '8', inclusive.
- king, pawnA and pawnB will be distinct.
- The king's starting position will not be threatened by a pawn.
Examples
"c4"
"e6"
"d5"
Returns: 2
The king has to capture B before A.
"c4"
"d5"
"e6"
Returns: 1
"g2"
"a8"
"a2"
Returns: 6
"g2"
"a7"
"e4"
Returns: 6
"a4"
"h4"
"c3"
Returns: 7
"a4"
"h4"
"b4"
Returns: 7
"b5"
"d3"
"e2"
Returns: 5
"a8"
"h1"
"g2"
Returns: 8
"h8"
"h7"
"g6"
Returns: 3
"a1"
"a2"
"b1"
Returns: 2
"a1"
"b1"
"a2"
Returns: 1
"f7"
"d5"
"c4"
Returns: 5
"a8"
"g2"
"b5"
Returns: 7
"a8"
"f2"
"b5"
Returns: 7
"a8"
"e2"
"b5"
Returns: 6
"a8"
"a1"
"b5"
Returns: 7
"a8"
"a1"
"a2"
Returns: 7
"b8"
"a1"
"b1"
Returns: 9
"b8"
"b1"
"c1"
Returns: 9
"b8"
"g1"
"f1"
Returns: 9
"b8"
"h1"
"g1"
Returns: 9
"c8"
"a1"
"b1"
Returns: 9
"c8"
"b1"
"c1"
Returns: 9
"c8"
"g1"
"f1"
Returns: 9
"c8"
"h1"
"g1"
Returns: 9
"d8"
"a1"
"b1"
Returns: 9
"d8"
"b1"
"c1"
Returns: 9
"d8"
"g1"
"f1"
Returns: 9
"d8"
"h1"
"g1"
Returns: 9
"e8"
"a1"
"b1"
Returns: 9
"e8"
"b1"
"c1"
Returns: 9
"e8"
"g1"
"f1"
Returns: 9
"e8"
"h1"
"g1"
Returns: 9
"f8"
"a1"
"b1"
Returns: 9
"f8"
"b1"
"c1"
Returns: 9
"f8"
"g1"
"f1"
Returns: 9
"f8"
"h1"
"g1"
Returns: 9
"g8"
"a1"
"b1"
Returns: 9
"g8"
"b1"
"c1"
Returns: 9
"g8"
"g1"
"f1"
Returns: 9
"g8"
"h1"
"g1"
Returns: 9
"h8"
"a1"
"b1"
Returns: 9
"h8"
"b1"
"c1"
Returns: 9
"h8"
"b2"
"a1"
Returns: 9
"h8"
"c1"
"d1"
Returns: 9
"h8"
"g1"
"f1"
Returns: 9
"h8"
"h1"
"g1"
Returns: 9
"a8"
"a1"
"b1"
Returns: 9
"a8"
"b1"
"c1"
Returns: 9
"a8"
"f1"
"e1"
Returns: 9
"a8"
"g1"
"f1"
Returns: 9
"a8"
"g2"
"h1"
Returns: 9
"a8"
"h1"
"g1"
Returns: 9
"c2"
"h7"
"d3"
Returns: 5
"c4"
"f7"
"d5"
Returns: 3
"d2"
"h6"
"e3"
Returns: 4
"d4"
"h8"
"f6"
Returns: 4
"e3"
"a7"
"d4"
Returns: 4
"f1"
"a6"
"d3"
Returns: 5
"f2"
"c5"
"e3"
Returns: 3
"f5"
"c8"
"e6"
Returns: 3
"g1"
"d4"
"f2"
Returns: 3
"g2"
"d5"
"f3"
Returns: 3
"h1"
"a8"
"e4"
Returns: 7
"h2"
"b8"
"f4"
Returns: 6
"h5"
"e8"
"g6"
Returns: 3
"b4"
"g8"
"d6"
Returns: 5
"c7"
"f7"
"d8"
Returns: 3
"d4"
"b2"
"d3"
Returns: 3
"e2"
"a1"
"d3"
Returns: 4
"f1"
"c6"
"c5"
Returns: 5
"f8"
"h2"
"g6"
Returns: 6
"g7"
"a1"
"e6"
Returns: 7
"h3"
"a7"
"g3"
Returns: 7
"h6"
"g1"
"f1"
Returns: 7
"c1"
"b1"
"b2"
Returns: 1
"d2"
"c3"
"c2"
Returns: 1
"d3"
"e4"
"d4"
Returns: 1
"e2"
"f3"
"e3"
Returns: 1
"f1"
"g2"
"f2"
Returns: 1
"g2"
"g3"
"h3"
Returns: 1
"g6"
"f7"
"f6"
Returns: 1
"h5"
"g6"
"h6"
Returns: 1
"h5"
"h6"
"g6"
Returns: 1
"h6"
"g6"
"g7"
Returns: 1
"h6"
"g7"
"g6"
Returns: 1
"h6"
"g7"
"h7"
Returns: 1
"h6"
"h7"
"g7"
Returns: 1
"h7"
"g7"
"g8"
Returns: 1
"h7"
"g8"
"g7"
Returns: 1
"h7"
"g8"
"h8"
Returns: 1
"h7"
"h8"
"g8"
Returns: 1
"a3"
"b1"
"c1"
Returns: 7
"a1"
"b1"
"c1"
Returns: 1
"e7"
"e6"
"d5"
Returns: 3
"c4"
"g8"
"d5"
Returns: 4
"f4"
"c7"
"e5"
Returns: 3
"h8"
"d6"
"c5"
Returns: 6