Problem Statement
Cat Snuke is playing a puzzle called Eight Rooks Puzzle.
In this puzzle, he must put exactly eight rooks onto an 8x8 chessboard. No two rooks must be in the same row, and no two rooks must be in the same column.
You are given a String[] board. The j-th character of the i-th element of board is either 'R' or '.'. If this is 'R', the cell in row i, column j contains a rook. Otherwise the cell doesn't contain a rook.
Determine whether Snuke solved the puzzle correctly. If he solved the puzzle correctly, return "Correct". Otherwise return "Incorrect".
In this puzzle, he must put exactly eight rooks onto an 8x8 chessboard. No two rooks must be in the same row, and no two rooks must be in the same column.
You are given a String[] board. The j-th character of the i-th element of board is either 'R' or '.'. If this is 'R', the cell in row i, column j contains a rook. Otherwise the cell doesn't contain a rook.
Determine whether Snuke solved the puzzle correctly. If he solved the puzzle correctly, return "Correct". Otherwise return "Incorrect".
Definition
- Class:
- EightRooks
- Method:
- isCorrect
- Parameters:
- String[]
- Returns:
- String
- Method signature:
- String isCorrect(String[] board)
- (be sure your method is public)
Constraints
- board will contain exactly 8 elements.
- Each element of board will contain exactly 8 characters.
- Each character in board will be either 'R' or '.'.
Examples
{"R.......", ".R......", "..R.....", "...R....", "....R...", ".....R..", "......R.", ".......R"}Returns: "Correct"
{"........", "....R...", "........", ".R......", "........", "........", "..R.....", "........"}Returns: "Incorrect"
The number of rooks is not eight.{"......R.", "....R...", "...R....", ".R......", "R.......", ".....R..", "..R.....", ".......R"}Returns: "Correct"
{"......R.", "....R...", "...R....", ".R......", "R.......", ".......R", "..R.....", ".......R"}Returns: "Incorrect"
The rightmost column contains two rooks.{"........", "........", "........", "........", "........", "........", "........", "........"}Returns: "Incorrect"