TopcoderArchive
Archive
Algorithm problem

FirstMazeTask

Problem statement, definition, constraints, and public examples.

Problem Statement

You are given a String[] maze representing a grid of cells. Empty cells are denoted as '.', occupied cells are denoted as '#', and all other cells contain uppercase letters. A maze is considered correct if there are at least 3 empty cells and all the letters are different.

If the maze contains less than 3 empty cells, return "There are less than 3 empty cells!". Otherwise, if there are at least two equal letters, return "There are at least two equal letters!". If the maze is correct, return "Everything is ok!". All quotes are for clarity only.

Definition

Class:
FirstMazeTask
Method:
checkCorrectness
Parameters:
String[]
Returns:
String
Method signature:
String checkCorrectness(String[] maze)
(be sure your method is public)

Constraints

  • maze will contain between 1 and 50 elements, inclusive.
  • Each element of maze will contain between 1 and 50 elements, inclusive.
  • Each element of maze will contain equal number of elements.
  • Each character in maze will be '.', '#', or 'A'..'Z'.

Examples

  1. {"A..",
     "#.#",
     "#.B"}
    Returns: "Everything is ok!"
  2. {"A.C",
     "#.#",
     "#DB"}
    Returns: "There are less than 3 empty cells!"
  3. {"A.B",
     "#.#",
     "#DB"}
    Returns: "There are less than 3 empty cells!"
  4. {"A.B",
     "#.#",
     "#.B"}
    Returns: "There are at least two equal letters!"
  5. {".....",
     ".....",
     ".....",
     "....."}
    Returns: "Everything is ok!"
Back to all problems