TopCoder problem "CompanyName" used in TCO05 Qual 4/6 (Division I Level One)



Problem Statement

    

You are choosing the name for your company. You have several proposals, and you want to choose the easiest to remember. Thus you calculate a special remembering value for each word, and choose the word with the smallest remembering value.

You can calculate the remembering value of the word in two steps. First, you should find all maximal groups of consecutive vowels (if the word is "DoUble", "oU" and "e" are the two groups). Each such group adds 1 point to the remembering value. Second, you should find all maximal groups of consecutive consonants. Each such group adds (2*(Length of the group) - 1) points to the remembering value.

Given a list of all proposals, return the one with the smallest remembering value. In case of a tie, return the proposal which comes first in the input.

 

Definition

    
Class:CompanyName
Method:shortestProposal
Parameters:String[]
Returns:String
Method signature:String shortestProposal(String[] proposals)
(be sure your method is public)
    
 

Notes

-For the purposes of this problem, we are always considering 'Y' to be a consonant. The vowels are only 'A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U' and 'u'.
 

Constraints

-proposals will contain between 1 and 50 elements, inclusive.
-Each element of proposals will contain between 3 and 50 characters, inclusive.
-Each element of proposals will contain only letters ('a'-'z' and 'A'-'Z').
 

Examples

0)
    
{"Top", "Coder", "SRM"}
Returns: "Top"
The remembering value of "Top" is 3, for "Coder" and "SRM" it is 5.
1)
    
{"SRM", "TCO", "TCCC"}
Returns: "TCO"
2)
    
{"java", "CPP", "CSharp", "VBasic"}
Returns: "java"
3)
    
{"aaa", "AAa", "aaA", "AAA", "AaA", "Aaa"}
Returns: "aaa"
The remembering value of all proposals is 1. You should return the first one.
4)
    
{"bIwuZFsHVQUWIABhgXYiyBmUgwSFvUfJKcGrKUb", "CbjspPBtuDwlyxNMaJBIEzVDPipR", "wGiqORBPEaKOYVwtiCmKHLkBS",
 "aBpRqKPBtxYNuGMhtXmgWxT", "sALonbrAMgOESizcTNhgBeAT", "PpnecUCIPdyyeOvZwVHygGgjthT", "jsiAzTEiBiXqgeSGd",
 "fxUtmmfbpQoYMPenNaTtKKoCYaIhwHBJePAFtvhVPDQHiLjDcr", "jIIOwgKw"}
Returns: "jIIOwgKw"

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=8023&pm=4563

Writer:

Olexiy

Testers:

PabloGilberto , lbackstrom , brett1479

Problem categories:

Simple Search, Iteration, String Manipulation