Problem Statement
Definition
- Class:
- TwoKings
- Method:
- captureKing
- Parameters:
- String, String, String
- Returns:
- int
- Method signature:
- int captureKing(String queen, String king1, String king2)
- (be sure your method is public)
Notes
- The black side tries to avoid capturing as long as possible.
- Kings move one cell in any direction, horizontally, vertically, or diagonally.
- The queen moves any number of cells in any direction, horizontally, vertically, or diagonally.
- The queen captures a king if it moves to the cell that the king occupies.
- Neither side can skip a turn.
- Pieces may not move off the board.
Constraints
- queen, king1 and king2 will each contain two space-delimited integers between 0 and 99, inclusive.
- The numbers in queen, king1 and king2 will not contain leading zeroes.
- No two pieces will occupy the same cell.
Examples
"0 0"
"1 1"
"99 99"
Returns: 1
You can capture a king on the first turn.
"0 0"
"99 0"
"0 99"
Returns: 1
You can capture any king on the first turn.
"1 1"
"90 0"
"0 30"
Returns: 2
"98 98"
"0 97"
"99 0"
Returns: 2
You can move to the "0 0" cell and threaten both kings. You will capture one of them on the next turn.
"99 0"
"1 1"
"0 98"
Returns: 2
"99 10"
"80 80"
"50 1"
Returns: 4
"0 0"
"35 57"
"48 49"
Returns: 4
"49 48"
"35 57"
"0 0"
Returns: 2
"0 0"
"4 5"
"30 80"
Returns: 4
"46 99"
"74 16"
"15 1"
Returns: 4
"16 35"
"53 36"
"23 40"
Returns: 3
"15 48"
"43 26"
"4 31"
Returns: 2
"57 79"
"72 35"
"92 0"
Returns: 2
"70 83"
"72 87"
"52 18"
Returns: 4
"82 99"
"60 12"
"72 13"
Returns: 4
"11 9"
"94 46"
"61 75"
Returns: 4
"8 54"
"64 89"
"38 61"
Returns: 4
"43 58"
"8 68"
"80 37"
Returns: 4
"96 72"
"87 69"
"90 20"
Returns: 2
"70 1"
"34 74"
"77 58"
Returns: 4
"60 96"
"11 44"
"17 22"
Returns: 4
"65 65"
"20 62"
"95 28"
Returns: 4
"44 11"
"25 99"
"68 95"
Returns: 3
"97 42"
"29 42"
"36 24"
Returns: 1
"25 2"
"55 3"
"57 51"
Returns: 3
"86 58"
"96 78"
"16 96"
Returns: 4
"53 53"
"65 81"
"67 54"
Returns: 3
"20 58"
"38 21"
"2 25"
Returns: 4
"56 23"
"86 79"
"44 96"
Returns: 4
"47 57"
"79 6"
"44 41"
Returns: 2
"53 90"
"35 86"
"47 10"
Returns: 4
"43 25"
"39 44"
"78 2"
Returns: 4
"91 34"
"55 50"
"33 82"
Returns: 4
"37 10"
"26 68"
"37 3"
Returns: 1
"22 62"
"56 63"
"28 95"
Returns: 3
"59 65"
"39 27"
"30 80"
Returns: 2
"95 22"
"91 2"
"87 47"
Returns: 4
"5 75"
"43 99"
"29 18"
Returns: 2
"22 53"
"95 64"
"30 76"
Returns: 4
"0 0"
"9 9"
"1 1"
Returns: 1
"10 9"
"0 0"
"20 30"
Returns: 2
"0 15"
"11 9"
"10 20"
Returns: 2
"20 80"
"21 15"
"0 99"
Returns: 2
"20 80"
"39 61"
"0 99"
Returns: 1
"5 95"
"0 13"
"13 18"
Returns: 2
"5 95"
"0 13"
"13 19"
Returns: 3
"95 95"
"1 0"
"0 1"
Returns: 2
"45 73"
"88 12"
"11 42"
Returns: 4
"99 0"
"1 1"
"0 47"
Returns: 2
"99 0"
"1 1"
"1 47"
Returns: 2
"55 30"
"53 22"
"11 64"
Returns: 2
"40 53"
"47 68"
"48 34"
Returns: 3
"31 3"
"59 64"
"60 12"
Returns: 3
"15 29"
"76 32"
"74 49"
Returns: 3
"62 90"
"91 36"
"95 35"
Returns: 3
"22 53"
"95 64"
"30 76"
Returns: 4
"64 75"
"12 20"
"25 9"
Returns: 3
"87 44"
"89 0"
"83 59"
Returns: 3
"1 2"
"0 0"
"60 80"
Returns: 2
"2 99"
"0 1"
"1 0"
Returns: 2