Connection Status:
Competition Arena > EllysPronunciation
Rookie SRM 10 · 2022-02-07 · by espr1t · Simple Search, Iteration, String Parsing
Class Name: EllysPronunciation
Return Type: int
Method Name: getGood
Arg Types: (vector<string>)
Problem Statement

Problem Statement

Elly is constantly learning new languages. Sometimes she has difficulties with the pronunciation, mainly caused by excessive presence of vowels over consonants or vice-versa in the words. She considers a word easy to pronounce if it has equal number of vowels and consonants. As you can see yourself, words like "allure", "voulez", "vorliebe", and "amor" are relatively easy to say out loud, unlike, for example, "wrath", "ecoeurement", "abneigung", or "odiar".

You are given the words that Elly has learned this week in the String[] words. Count how many of them are "easy" to pronounce (i.e. have equal number of vowels and consonants).

Notes

  • For this problem we will consider the letters 'a', 'e', 'i', 'o', and 'u' to be vowels, and all other - consonants.

Constraints

  • words will contain between 1 and 50 elements, inclusive.
  • Each element of words will contain between 1 and 50 characters, inclusive.
  • All elements of words will contain only lower-case letters of the English alphabet ('a'-'z').
Examples
0)
{"wrath", "allure", "vorliebe", "abneigung", "amor", "voulez", "ecoeurement", "odiar"}
Returns: 4

The example from the problem statement.

1)
{"schornsteinfeger", "schmetterling", "lohnsteuerabzugsbescheinigung", "shifffahrt",
 "deutsch", "ist", "die", "schoenste", "sprache", "auf", "der", "welt"}
Returns: 0

The German is a horrible language.

2)
{"hearing", "vision", "smell", "touch", "taste",
 "denial", "anger", "bargaining", "depression", "acceptance",
 "war", "famine", "plague", "death",
 "pog", "story", "sarah", "gender", "baleen",
 "posh", "sporty", "scary", "ginger", "baby", "spice"}
Returns: 5

Here the good words are {"vision", "denial", "famine", "plague", "baleen"}.

3)
{"this", "was", "a", "triumph",
 "i", "am", "making", "a", "note", "here", "huge", "success",
 "its", "hard", "to", "overstate", "my", "satisfaction"}
Returns: 5

It is possible that some of the given words are repeated, or consist of a single character. Please also note that in this problem we consider 'y' to be a consonant.

4)
{"wir", "werden", "alle", "sterben", "haltet", "euch", "bereit",
 "die", "zeichen", "sind", "eindeutig", "bald", "ist", "es", "soweit",
 "vielleicht", "schon", "heute", "abend", "vielleicht", "in", "einem", "jahr",
 "doch", "alle", "verden", "sterben", "traurig", "aber", "wahr"}
Returns: 8

Here the eight good words are: "alle", "euch", "bereit", "es", "soweit", "in", "alle", and "aber". Please note that each good word should be counted as many times as it is present in the list (in this example "alle" should be counted twice).

Submissions are judged against all 112 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class EllysPronunciation with a public method int getGood(vector<string> words) · 112 test cases · 2 s / 256 MB per case

Submitting as anonymous