TopCoder problem "Pronunciation" used in SRM 240 (Division II Level One)



Problem Statement

    Peter has problems with pronouncing difficult words. In particular he can't pronounce words that contain three or more consecutive consonants (such as "street" or "first"). Furthermore he can't pronounce words that contain two or more consecutive vowels that are different (such as "goal" or "beauty"). He can pronounce words with two consecutive equal vowels though (such as "need").



Is this problem we consider the 'y' to be always a consonant, even in words like "any". So the vowels are 'a', 'e', 'i', 'o' and 'u'. You are given a String[] words. If Peter can pronounce all the words, return an empty String; otherwise return the first word he can't pronounce.
 

Definition

    
Class:Pronunciation
Method:canPronounce
Parameters:String[]
Returns:String
Method signature:String canPronounce(String[] words)
(be sure your method is public)
    
 

Constraints

-words contains between 1 and 50 elements, inclusive.
-Each element of words has length between 1 and 50, inclusive.
-Each element of words consists of upper- and lowercase letters.
 

Examples

0)
    
{"All","of","these","are","not","difficult"}
Returns: ""
1)
    
{"The","word","REALLY","is","really","hard"}
Returns: "REALLY"
2)
    
{"TRiCKy"}
Returns: "TRiCKy"
Since the 'y' is a consonant, this word contain three consecutive consonants.
3)
    
{"irresistable","prerogative","uttermost","importance"}
Returns: ""
Peter can pronounce these words.
4)
    
{"Aa"}
Returns: ""

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=3527

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=6539&pm=3527

Writer:

Jan_Kuipers

Testers:

PabloGilberto , lbackstrom , brett1479

Problem categories:

Brute Force, Simple Search, Iteration, String Manipulation