Problem Statement
Definition
- Class:
- TurtleGame
- Method:
- getwinner
- Parameters:
- String[]
- Returns:
- String
- Method signature:
- String getwinner(String[] board)
- (be sure your method is public)
Constraints
- board will contain between 2 and 20 elements, inclusive.
- All elements in board will contain the same sumber of characters.
- Each element in board will contain between 2 and 20 characters, inclusive.
- Each character in board will be either '.' or '#'.
- It is guaranteed that there is at least one undestroyed turtle path.
Examples
{"..", ".."}
Returns: "Win"
This board contains two different turtle paths. Hero has two moves that don't lose him the game: he can remove either the top right or the bottom left cell. Each of these moves will leave only one of the two turtle paths, and Jack will have no valid moves left. Jack's move will create a board that is not turtle-friendly, which means that Hero will win the game.
{"...", ".#.", ".#.", "..."}
Returns: "Lose"
Again there are only two turtle paths. However, now they are longer. Regardless of which cell Hero removes (other than the top left and the bottom right cell), his move will create three cells that can be destroyed "for free". Since 3 is an odd number, Jack will be the one to remove the last of these three cells. In the following turn Hero will lose the game.
{".##", "..#", "#.."}
Returns: "Lose"
{"....", "...#", "#...", "...."}
Returns: "Win"
{"...#.", "....#", "#....", "..##."}
Returns: "Win"
{"..........", "........#."}
Returns: "Lose"
{"...........","...........","...........","...........","....#......","...........",".......#...","...........","..........."}
Returns: "Lose"
{"....#",".#...",".#...",".#.#.",".....",".....","...#.","...#.","#...."}
Returns: "Lose"
{"..........#.......","..........#....#..","...........#...#..",".....#..#........#",".........##....#..",".....#............",".............#....","...#...........#.."}
Returns: "Lose"
{"..##............","...........#...#","........#.......","..........#.....",".....#......##.#",".............##.",".....#....#.....",".......#...#.#..",".#...........#..",".............#..","..............#.","..#.............","................",".#........#.....","#.......#.......","##..............","..#.##.........."}
Returns: "Win"
{"...",".#.","...","..."}
Returns: "Win"
{"..#.","#...","....","...#","...#",".#..","...."}
Returns: "Win"
{"...##...........","#........#......","............#...",".#..........#...","......#.........",".....#....#..#..",".....#.#...#....","......##........"}
Returns: "Win"
{"............",".........##.",".#.##...#.#.","..#.........","#.....#...##","..........#.","...#.#......","..#...#.....",".##.#.......",".......#.#..","...#..#....#",".......#..##","##...#....##","..#....##...","..#........."}
Returns: "Win"
{"...............","#.....#........","...............",".....#....#....","...............",".##............","...............","...............",".............#.","......#..#...##","...............","......#........","..........#....",".....#........."}
Returns: "Lose"
{".#..##...#.....#...","...................","......#......#.....","..................."}
Returns: "Win"
{"...",".#.","...",".#."}
Returns: "Lose"
{"..#.......##....","#.......#.......",".........#......","............#...","#.....#...#..#..","........#.......",".......#.......#","##...#...##.....","................","#....#........#.",".#......#..#....",".#...###..#.....","........#.......","#............#.."}
Returns: "Lose"
{"....#.#....#...##",".......#.##......","............#....",".................","..........#......","..#..#.#.........",".#.#...........#.","#.....#....#.....","...#....#........","..........##.....","....#............",".........#..#....",".#...#...........","..#.....#........"}
Returns: "Lose"
{"...............",".#.#.#..#..#...","#.....#...#....","...#.......#..#","......###......","........#......",".....#.#.##..#.",".##..#.#....#..","#.............#","...#...........",".#..#...#...##.","#........#.#...",".....#....#...."}
Returns: "Lose"
{".#.........#","..........#.",".#..........",".......#.##.","..#....#....","#...##...#..","..........#.","............","...#........","..##...#...#","#...........","............"}
Returns: "Win"
{".....","..##.",".....",".....",".....",".....",".....",".#...",".#...","....."}
Returns: "Lose"
{"..##.........","#...........#",".............","#..#.#....#..","........#.#..","......#...#..","..#....##....","...#.........","...#.........",".....#..#....",".....###..#..",".............","............."}
Returns: "Win"
{"...##....",".#.###...","....#....",".##...###",".#......#",".#..##..#","....#....","..#...#..","##..#....",".........","#...#....","#..#.#...","...#....#","#...##..."}
Returns: "Lose"
{"...#...",".......","......."}
Returns: "Win"
{"..................","..................","..................",".................."}
Returns: "Win"
{"...##..##..#...#.##",".#...#.#....#...##.",".###.#.....#.#.#...","...........###.#...","..#.#...#....#...#.","##.##..#...#.#.....",".#..#.#.#..#.......",".#.##..##.#.#.#..#.",".....##.....###.#..","#.#.#...#.....#....","..#...#.#####......","..#....##.##.##...."}
Returns: "Lose"
{".#..#........##..",".###.....#.#.#...","..#....#.....#...",".......#..##.##.#","#.............#..",".#.....#..###....","....##......#....","...#.#....#....##","##.######.##.....","..##....#..####..",".##.#.#..#.#..#..","..#...##..##.#...","##.#...#...#.....","#....##.....#...#",".#...#........#.."}
Returns: "Win"
{".#..#...##.#....","...#..#..#.#.#.#","##.............#","..#.#.#.#.#..#..",".#....##..#.#.#.","###....#...##.#.",".#...#....#...#.","#...#.##..#.#..#","...#..#.......#.","#.....#.#####...","..#..#........##","...##.#.###...##","#..#.#..#.#.#...","....#..#.#......"}
Returns: "Lose"
{"........#..#..","##....##...#..",".........#..#.","...##....#.#..","...##.###....#","#..##....#.#..","..##..#.#####.","#.###..###..##","......#..#....","....#...#.#..#","##...#....##.#",".##...........","...#.##...#.#."}
Returns: "Lose"
{".#..##..#..#..#.##.","..###.##..##.###..#",".....#..###....###.","#..........#...#...","....#.#..#.###...##","###.....#..#####.##",".#..#....####..###.","##....#####.#......","#..#.#.#..#..###..#","#.......#....##.#..","...#...#..###..##..","....#........##.#.#",".##.....##..#..#...","#.##.#...#...####.#","...#....###....##..","#.#...#.##.###.#.#.",".#..##..........#..","#..##..##.#.#....#.","....###...###.#....","#...#...####..#...."}
Returns: "Win"
{"........#.",".#.##.....",".##...#.#.","###.#.....","#..#.#..##","#..##.....",".###.##...","#.#.......","......#...","..##....#.",".#.#......","..##.###..","...##...#."}
Returns: "Win"
{".#.###.#...#..","..#.###...#..#","#.......#.#.#.","...#.##.##..#.","#.....#.#....#","..##..........","##.#.#........","....#.#.#..#..","..##.#.#.#..##",".####.##.#..#.",".#.#.#...#..##",".....##.#....."}
Returns: "Win"
{".#####.##.........",".......##..#...##.",".###.##..#..##...#","..#.###......#.#..",".............##...","...#.######.#.##..","..#....#.#....###.","..........###.##..","###.#....#.....##.","###.....#...#...#.","###..##......#...."}
Returns: "Win"
{"....#..##.....","#.#..#..##.###","....###.#..#..","#..##...#...#.","..###....##..#","....#.#.#####.",".##...###...##","#.........##..","...#...#.....#","#...#.##......",".#.#.#.##...#.","#.....#......#",".#.#....#..#..","###.#.#....#..","####..##...#..","..............","###..#...#.##.","...##.#....#.#","##.#..#.......","####...##.##.."}
Returns: "Lose"
{".#.#..##..#..#.....",".....#....#.#.#....",".....#..##...#.....","#..#.#..........##.","####....#....#....#","#.###..##....#....#","#..#..##.....##.##.","...##.........#....",".#.......##..#.#...","#.#......##......#.",".....#....##..#.###","......#....#..#...#","....#.#....#...###.",".#...........#...#.","##.#...#....#......"}
Returns: "Lose"
{".......#.#..#.##.","...#...#.####...#",".#.##.....#....##",".#......#.#.#..#.",".....#...#..#....","#..###..#..##.#..",".#...#..#.....#.#","#.#..#..####..##.","#.#....#........#","...##...##.#...##","...#....#.###....",".#.........#....#","#.#..............","#.#....##.#.#.#..","#.#.#...##.#....."}
Returns: "Lose"
{".#.#.......#..#.#.",".##.#...#.....#.##","..##...#.......##.",".....#.#.##.....##","#.#.#....#.##.#.#.",".........#.##.###.","...#.#.#..####.##.",".#..#.#.....#.##..",".###.....#.#..#...",".#....##...#.##.##",".##....##........."}
Returns: "Lose"
{"...###.....##..##","....#...#.####..#","...#.#......#..##",".#.....###...#.#.","....#.......#.##.","......#.........#","#.......###.#....","...#.##....#.....","...###....#......","..#..#...........",".#......#..#.....","....#..#.#..##.#.","#.#...#.###..#...","#.#.#..####.#..#."}
Returns: "Win"
{"....#...#.","........#.","....#..#..",".#......#.","..##...#.#","...#.#.#..","#....#....","..#.#.#.##",".#.#..#..#",".#..###.##",".#........"}
Returns: "Lose"
{"...##..#.#",".#....#.#.","###..##..#",".......###","#....#....","..#.....##","..##...#..","##.#.#...#","...#...#..","##..#..###","..#.......","..##..#..#",".........."}
Returns: "Lose"
{"......#..#..","....#.....#.","..#...#.#.#.",".##..#......","..###....#..",".......#....","##.#......##",".....####.#.","......###..#","...#...##...","....##.##..#",".#...##...##","#..#..#....#",".#...##.#.#.","#..#.#.##...",".#...##.#.##","#..#.....#..",".#.##......#","#........##.",".....##....."}
Returns: "Lose"
{"...#....##...#.","##...##.....#..","..........#...#",".....#..##.....",".##..#...#..#..","#..#.......##..","###....##....#.","..#..#.....#.#.","#...#.#..#.....",".....#.....#...","...#...#...#.#."}
Returns: "Win"
{"...#.##.....#..","#........##...#",".#.....#.#####.","##..#..#.#.###.","#..#......#.#..",".....#.##....#.","#.......#.#...#","##.##.###.#..#.",".###..#..#.....","#.##.####.#...."}
Returns: "Win"
{".#.#..#...##......#",".##..##....##......","...##.#.#..#.#.....","#.#..#.#.#.#####...","......#.......#.#..","#.........#...#....","...#...#...#...#...","##...#......#.....#","#.##....#....#....#","....#..#..#..#..#.#",".#..#.#.##..#.....#",".....#....#.....#.#","#..##..###...##.#..","...#.#.#.#..#.#.#..","...#.#####...#.....","####..#..#.##....##","....#..##.#.###..##","##..#...#.##....#.#","..#.#..#.#.#..#...."}
Returns: "Lose"
{".....#........###.",".##....###.......#","......##...####...","....#..#....#.....","....#..#...#.....#",".#.#.#......#.....",".#.###......###.#.","......##....##..##",".#.##.#...........",".....##..#..#.#..."}
Returns: "Win"
{".#.#..#....",".....#.#..#",".....####..","....###..#.","..#........","..#.###....","...#.#.##..","##.....#.##","...###.#...","#...##..###",".##..#..#.#","#.#.......#","###...###.#",".#.##.#....","........##.","..#....#.#."}
Returns: "Lose"
{"....#.#.#.#.#","..#..#.#...#.","##....#.....#",".#..#........",".#....####..#","#.#.......#..","##.#.....#...","#.#......###.","#..#..#....#.","...#..#......"}
Returns: "Win"
{"...#.##.......#...","..##.....#..#..###","............##...#","#..#.#....#...##.#","....#.#.#...##...#",".......#.#...##..#","##.##.#..##...####",".#....##...#..##..",".#......###.#.....",".#####......#.#.##","##..#......#.##..."}
Returns: "Win"
{"........#.#.#","..#.##...##..","..#...#....#.",".#.#.####.#.#","..##....#.#..",".#.#....#..#.","####.....#...","##....##.....","..#..####..##",".#.#..##.##..","#........##..",".#.##.....##.","...#..#.##...","..#..#.....##",".....#..##..#","......#.....#",".....#....##.","...##...#...."}
Returns: "Win"
{"...##.#.#..###.#","#...###.......##","###...#..#..####","#..##.##.#.###..","...#..###.....##","##..#..##.#.##.#","#.#...#....#.#.#","...........#..#.","...#.#.#.#.#..##",".....#.#.#.....#","..##...#...#....",".#.......##.##..",".#...#.#....#.##","#...#..#..#..##.","###.....#.#.###.",".##..........#.#","##..##.#........","..##...#.#....##","##.....#..#...##","#..#...#.##.#..."}
Returns: "Win"
{"..###...........","...#.#.#.....#..","#.#..#.#.#..#.#.","....#......#..##","..#..##.#.#.#.#.","#...##.##....##.",".....#.#####.#..",".#...##...#..#.#",".###....#....##.","..##..#.##...###","#.....#........."}
Returns: "Win"
{".##.....#.#","....##.....",".....#..#..","###.#......","##...#..#..",".....#.....",".#..#......",".#...##.##.",".......##..",".#...#..###","...#..#..##","...#.#.#.##","#..........","..#.#...##."}
Returns: "Win"
{".#.##.##.......","......#........","#.#.#.....###..",".#.#.##.....#..",".#.#..#..#.....","##.##......##..","##..#.#..##....",".#......#...#.#","....#.#.###....","##...##.....#.#","#..##.#..###..#","...#..#.....#.."}
Returns: "Win"
{"........#..#....","..##....#.#.####","...###...#.....#","#.....##.......#","#......#...#....","#..#..#..#......","....#.###.#....#","..#...###..#.#.#","#...#.##.#....#.",".##......#.#.#..","#.##..#....#....","....#.#.##.#...#","##..##.#.##.##..",".#..#.#.##.#....","...##..###......","##...#..#...#.#.",".####..#.##.##..","#.#.#..###..#...","......##..#.....",".........#.##..."}
Returns: "Lose"
{".#..###..#....",".#.......##...",".......#.#...#",".....#..#....#","#.##.###..####","#.##.#.#.....#","........##..##","........##.##.","#.......#..#..",".##.......#.##",".##.....#....."}
Returns: "Win"
{".....#####.",".....#..#.#","#.#..#.....","....####.##","#..#...##..","#...#...#..","......#.#.#","...........",".#....#.#.#","......##...","#..#.##...#",".##.....#..","#........##","...#.#.....","#.#####.##.",".#..#.#.###",".#..#......","#.#........"}
Returns: "Lose"
{".#.#....####.##.##.#",".#......##.####.#.#.","..##..###....##.....","......#.....##...##.","....###..........#..","......###..##....###",".......#......##...#","###.......#..#....#.","........#..#...#....",".#.#.#.#......#.....",".#.###......###.#...","....##....##..##.#.#","#.#................#","#..#..#.#..##.#..#.#","..#..#...#.......#..","...#..#.#.##........"}
Returns: "Lose"
{"...##..........###.","#...#.....##.##.##.","#.........#..#...#.","..##..##...#..###..",".#.#.##.###.#......","...........#...#.##","..#.#..##...#.#.##.",".#..#.###..........","...#......##.#.##..",".....#.#....#..#..#","##.#.....#..#...#..","#....#....#.##...#.","...#.#..#.#.#..###."}
Returns: "Win"
{"...", "...", "...", "..." }
Returns: "Lose"
{"....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "....................", "...................." }
Returns: "Win"
{"...#.", "....#", "#....", "..##." }
Returns: "Win"