Statistics

Problem Statement for "WordSquare"

Problem Statement

PROBLEM STATEMENT

Class: WordSquare
Method: isWordSquare
Arguments: String[]
Returns: boolean

The local newspaper, Werd Times, has decided to incorporate a new sort of
crossword puzzle into their "fun and games" section of the Sunday paper.
However, in order to do this, they must first know whether or nor a series of
words can be arranged in a rectangle such that all words, across and down, are
valid. To determine this, arrange all words on top of each other
(left-justified - all words start in the same column) and then determine if all
columns form valid words and all rows form valid words. Words are arranged in
the order they are passed in.

A valid word meets the following criteria:
1. No spaces may exist in the midst of the word.
2. There must be at least one vowel, where vowels are A, E, I, O, and U.
3. There cannot be more than 5 consonants consecutively
4. There cannot be more than 4 vowels consecutively ('Y' is NOT considered a
vowel)

Here is the method signature (make sure your method is public): boolean
isWordSquare(String[] input);

TopCoder will enforce the following restrictions:
- Each String in input will contain only uppercase letters 'A'-'Z'
- Each String in input will be between 1 and 10 letters in length, inclusive.
- There will be between 1 and 10 words in input.

Example:
{"WOOD", "PUMPKIN", "GARBAGE", "EATER"}
becomes:
WOOD
PUMPKIN
GARBAGE
EATER

Clearly, the four horizontal words are legal.
Vertically, we get "WPGE", "OUAA", "OMRT", "DPBE", "KAR", "IG", "NE".
These all follow the 4 criteria for valid words, thus the return value is true.

{"ALPHABET","SOUP","GANGRENE"}
becomes:
"ALPHABET"
"SOUP"
"GANGRENE"
And we get "ASG", "LOA, "PUN", "HPG, "A R", "B E", "E N", "T E"
This returns false, since "HPG" is not a valid word (no vowel), and "A R", "B
E", "E N", "T E" are also invalid (no spaces allowed).

Examples:
{"THIS","THAT","ELSE","ATTN"} returns false
{"HELLO","WORLD","JAVAROCKS","TOPCODERI","ATOMICBA"} returns true
{"ABCD","BCDE","CDEF","DEFG","EFGH"} returns true
{"ZBCD","BCDE","CDEF","DEFG"} returns false

Definition

Class:
WordSquare
Method:
isWordSquare
Parameters:
String[]
Returns:
boolean
Method signature:
boolean isWordSquare(String[] param0)
(be sure your method is public)

Constraints

    Examples


      This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: