Problem Statement
In each turn a player must choose one queen and move with it. From position (x, y) a queen can be moved to (x - k, y) or (x, y - k) or (x - k, y - k), where k > 0. (Queens can move through squares containing other queens, and multiple queens can coexist on a single square). The two players alternate turns, and Alice goes first. The first player who moves any queen to the position (0,0) will become the winner. You are given the initial positions of the queens in the
Definition
- Class:
- ChessTraining
- Method:
- game
- Parameters:
- int[], int[]
- Returns:
- String
- Method signature:
- String game(int[] x, int[] y)
- (be sure your method is public)
Constraints
- x will contain between 1 and 50 elements, inclusive.
- y will contain the same number of elements as x.
- Each element of x and y will be between 0 and 99, inclusive.
- No queen will be at position (0,0) at the beginning.
Examples
{3,4}
{3,5}
Returns: "Alice will win"
Alice can move a queen from (3,3) to (0,0) to win in her first move.
{1}
{2}
Returns: "Bob will win"
No matter how Alice moves the queen, Bob can win in the next move.
{5,1,2,6,7}
{8,4,9,11,5}
Returns: "Alice will win"
{5,7,3,5}
{8,3,7,8}
Returns: "Bob will win"
{3,3,18,6,0,14,1}
{4,4,11,9,9,9,9}
Returns: "Alice will win"
{9,19,29,31,10,72,57,73,2,19,62,67,83,70,24,78,16,16,59,56,75,9,2,26,26,55,43,19,5,42,66,54,17,51,1,28,79}
{58,57,81,33,35,20,73,62,44,23,78,17,82,7,8,8,9,74,74,64,73,9,69,32,75,80,5,82,81,73,77,12,3,30,45,38,51}
Returns: "Alice will win"
{1,2}
{3,3}
Returns: "Alice will win"
{3,4,3}
{2,2,1}
Returns: "Bob will win"
{13,6,25,32,1,16,31,29,3}
{35,21,6,34,27,29,12,10,35}
Returns: "Alice will win"
{23,0,7,3,26,28,18,4,28,16,29,29,12,25,26}
{28,14,22,11,6,4,14,25,0,24,28,22,26,7,27}
Returns: "Alice will win"
{16,2,7,2,8,1,15,5,10,5,4,15,9,13,15,11,3,11,9,13,3,16,5,3,6,5,4,11,5,2,10,3,2,17,3,11,0,0,16,11,4,3,6}
{11,14,1,2,15,13,11,11,16,8,14,1,14,1,4,8,4,6,16,5,8,15,9,17,13,9,16,4,11,17,10,5,11,12,7,8,7,17,1,3,7,14,2}
Returns: "Alice will win"
{12,13,4,21,19,17,21,16,11,20,12,17,12,20,20,14,6,7,9,12,5,9,14,13,10,18,13,3,8,21,3,19,10,7,18,7,2,16,1,12,14,11,7,5}
{9,5,17,13,10,4,4,14,11,16,5,0,12,16,1,19,15,4,16,3,10,10,10,10,4,9,0,17,20,8,20,5,11,15,19,0,17,21,14,7,13,17,5,4}
Returns: "Alice will win"
{27,17,5,5,2,33,23,23,13,4,8,28,21,19,22,3,22,17,4,21,33,17,2,19,10,20,26,15,28,34,20,19,15,5,4,33,2,7,0,31,11,9,23,12,28,25,15,30,23}
{35,16,20,17,18,20,7,2,26,23,10,24,23,29,19,28,13,17,10,21,17,21,12,6,9,5,14,14,0,9,1,0,25,2,33,23,22,4,26,28,7,0,17,30,10,16,2,23,13}
Returns: "Alice will win"
{14,8,67,7}
{13,11,40,23}
Returns: "Bob will win"
{20,33,57,32,23,55,11,7,58,29,34,41,46,54,3,45,44,48,57,43,53,55,40,21,54,5,57,20}
{17,28,29,21,53,19,54,16,14,5,15,5,26,50,46,12,36,49,49,12,29,46,55,15,33,28,36,27}
Returns: "Alice will win"
{2,9,8,1,9,9,2}
{4,1,6,3,4,5,5}
Returns: "Bob will win"
{15,4,9,8,3,9,9,2,13,8,40,23,29,57,14,56,14,56,99}
{99,2,1,6,1,4,5,5,14,11,67,7,57,29,56,14,56,14,15}
Returns: "Bob will win"
{77,27,8,17,73,8,67,49,36,10,41,59,66,11,44,71,22,37,34,82,0,66,17,73,80,49,36,45,39,45,43,21,72,49,38,51,57,12,5,91,21,46}
{57,87,56,7,65,76,42,5,66,42,71,81,20,56,37,54,8,75,4,52,3,74,6,40,32,64,50,38,60,71,82,25,66,45,32,36,29,72,41,2,21,17}
Returns: "Alice will win"
{1,61,13,48,21,75,27,36,12,25,33,23,30,87,70,79,48,79,73,2}
{82,83,85,25,29,2,71,50,10,30,21,33,2,56,81,45,42,20,82,55}
Returns: "Alice will win"
{17,26,13,27,46,31,15,10,36,5,20,18,11,42,32,46,29,21,20,34,22}
{27,34,40,33,22,48,30,13,47,0,30,23,14,9,22,47,24,32,35,32,4}
Returns: "Alice will win"
{48,21,10,38,14,32,42,38,51,53,23,29,2,22,49,10,31,22,50,2,6,26,19,43,21,3,8,53,2,39,43,51,47,40,34,48,4,8,31,1,48,0,17,51}
{9,54,6,40,21,44,29,14,15,48,44,23,51,39,8,54,11,52,37,3,37,16,52,42,11,15,30,4,15,34,0,11,33,7,39,41,51,13,0,53,7,31,22,45}
Returns: "Alice will win"
{23,48,79,62,18,81,19,14,1,17,18,30,41,20,79,69,35,46,95,60,20,83,63,44,81,92}
{30,41,43,5,74,66,84,88,63,6,6,16,51,7,34,3,37,9,24,19,78,90,96,11,53,20}
Returns: "Alice will win"
{52,2,46,7,56,66,32,43,1,63,74,43,46,80,39,36,21,49,77,52,5,0}
{12,9,80,60,34,33,31,34,26,3,36,72,10,13,55,45,56,59,29,47,20,75}
Returns: "Alice will win"
{66,25,71,8,59,43,78,48,73,67,75,57,64,15,30,80,72,58,7,37,57,71,48,34,74,34,41,34,25,47,84,6,72,27,56,46,27,50,52,57,74,42,29,53,15,16}
{6,44,75,13,81,47,42,2,39,73,36,80,22,61,0,21,25,72,5,81,34,32,46,43,46,77,0,76,3,57,49,9,17,39,64,55,44,21,57,83,9,51,35,31,69,35}
Returns: "Alice will win"
{15,14,26,36,33,39,19,35,2,21,43,40,39,9,31}
{23,14,35,48,45,27,13,33,48,49,5,5,43,18,6}
Returns: "Alice will win"
{15,6,23,4}
{0,7,7,9}
Returns: "Alice will win"
{33,18,15,16,11,12,29,15,22,2,1,34,1}
{21,37,49,18,10,27,31,9,44,3,3,1,18}
Returns: "Bob will win"
{33,18,15,16,11,12,29,15,22,2,1,15,38,14,41,38,24,11,15,1,12,14,21,37,49,17,18,10,27,31,9,44,3,3,19,7,16,48,47,43,12,16,14,15,11}
{21,37,49,18,10,27,31,9,44,3,3,19,7,16,48,47,43,12,16,12,15,17,33,18,15,16,11,12,29,15,22,2,1,15,38,14,41,38,24,11,15,1,12,14,16}
Returns: "Alice will win"
{33,18,15,16,11,12,29,15,22,2,1,15,38,14,41,38,24,11,15,1,12,14,21,37,49,17,18,10,27,31,9,44,3,3,19,7,16,48,47,43,12,16,14,15,44,1,11,2}
{21,37,49,18,10,27,31,9,44,3,3,19,7,16,48,47,43,12,16,12,15,17,33,18,15,16,11,12,29,15,22,2,1,15,38,14,41,38,24,11,15,1,12,14,1,66,16,3}
Returns: "Bob will win"
{99,98,97,93,92,99,98,97,93,92,99,98,97,93,92,99,98,97,93,92,99,98,97,93,92}
{2,3,97,5,6,7,8,2,3,4,5,6,7,8,2,3,4,5,6,7,8,2,3,4,5}
Returns: "Alice will win"
{0,1,0}
{1,0,1}
Returns: "Alice will win"
{97,92,92,97,97,92,92,97,97,92,92,97,97,92,92,97,97,92,92,97,97,92,92,97,97,92,92,97,97,92,92,97,97,92,92,97,97,92,92,97}
{84,91,91,84,84,91,91,84,84,91,91,84,84,91,91,84,84,91,91,84,84,91,91,84,84,91,91,84,84,91,91,84,84,91,91,84,84,91,91,84}
Returns: "Bob will win"
{14}
{14}
Returns: "Alice will win"
{5}
{0}
Returns: "Alice will win"
{5,23,16,18,13,11,82,81,73,24,9}
{14,4,3,55,81,32,75,46,22,42,12}
Returns: "Alice will win"
{14,4,3,55,81,32,75,46,22,3,42,12}
{5,23,16,18,13,11,82,81,73,2,24,9}
Returns: "Bob will win"
{11,29,18,20,13,3,15,15,19,28}
{7,24,11,10,7,18,18,8,18,15}
Returns: "Alice will win"
{14,51,19,78}
{82,3,52,2}
Returns: "Bob will win"
{22}
{36}
Returns: "Bob will win"
{49,39,6}
{18,20,22}
Returns: "Alice will win"
{46}
{75}
Returns: "Bob will win"
{11,20,8,12,15}
{4,8,5,9,10}
Returns: "Bob will win"
{1 }
{3 }
Returns: "Alice will win"
{89, 6, 81, 17, 80, 51, 2, 78, 62, 17, 38, 63, 44, 97, 4, 84, 84, 78, 3, 11, 87, 73, 68, 66, 60, 60, 24, 53, 19, 70 }
{82, 76, 77, 44, 25, 15, 79, 39, 64, 41, 24, 73, 53, 12, 41, 2, 36, 31, 65, 20, 88, 32, 67, 69, 66, 48, 86, 60, 5, 34 }
Returns: "Alice will win"
{1, 3 }
{2, 3 }
Returns: "Alice will win"
{1, 0 }
{0, 1 }
Returns: "Alice will win"
{1, 5 }
{3, 3 }
Returns: "Alice will win"
{1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7 }
{2, 3, 4, 5, 6, 7, 8, 2, 3, 4, 5, 6, 7, 8 }
Returns: "Bob will win"
{43, 31, 76, 54 }
{32, 86, 11, 23 }
Returns: "Alice will win"
{5, 1 }
{0, 2 }
Returns: "Alice will win"
{3 }
{0 }
Returns: "Alice will win"
{5, 2 }
{4, 7 }
Returns: "Alice will win"
{0 }
{3 }
Returns: "Alice will win"
{1, 1, 2 }
{2, 3, 3 }
Returns: "Alice will win"
{4, 7 }
{3, 8 }
Returns: "Alice will win"
{3 }
{2 }
Returns: "Alice will win"
{1, 1 }
{4, 6 }
Returns: "Alice will win"
{3 }
{3 }
Returns: "Alice will win"
{3 }
{6 }
Returns: "Alice will win"
{1, 1, 1, 1 }
{2, 2, 3, 3 }
Returns: "Bob will win"
{2 }
{3 }
Returns: "Alice will win"
{3 }
{5 }
Returns: "Bob will win"
{2, 2, 1, 5 }
{1, 1, 2, 8 }
Returns: "Alice will win"
{10, 11 }
{40, 39 }
Returns: "Alice will win"