TopcoderArchiveVisit Topcoder
SRM26 Mar 2015
SRM 657

EightRooks

Problem statement, definition, constraints, and public examples.

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".

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

  1. {"R.......",
     ".R......",
     "..R.....",
     "...R....",
     "....R...",
     ".....R..",
     "......R.",
     ".......R"}
    Returns: "Correct"
  2. {"........",
     "....R...",
     "........",
     ".R......",
     "........",
     "........",
     "..R.....",
     "........"}
    Returns: "Incorrect"
    The number of rooks is not eight.
  3. {"......R.",
     "....R...",
     "...R....",
     ".R......",
     "R.......",
     ".....R..",
     "..R.....",
     ".......R"}
    Returns: "Correct"
  4. {"......R.",
     "....R...",
     "...R....",
     ".R......",
     "R.......",
     ".......R",
     "..R.....",
     ".......R"}
    Returns: "Incorrect"
    The rightmost column contains two rooks.
  5. {"........",
     "........",
     "........",
     "........",
     "........",
     "........",
     "........",
     "........"}
    Returns: "Incorrect"
Back to all problems