Hawaiian
TCCC '04 Round 1 · 2004-02-23 · by zoidal
Problem Statement
Many languages, including English, French, Spanish, and German use Latin characters (a-z). Hawaiian, as well, uses these characters. However, only a small subset of these characters are used in the Hawaiian alphabet - the five vowels: 'a', 'e', 'i', 'o', 'u', and seven consonants: 'h', 'k', 'l', 'm', 'n', 'p', 'w'. Given a sentence of words, you are to determine which could possibly be Hawaiian words. Anything which contains a letter not in the Hawaiian alphabet cannot be Hawaiian; every other word can be.
A word is defined as a contiguous sequence of letters. You will be given a sentence of words. You must tokenize them using a space (' ') as a delimiter, remove the words which cannot be Hawaiian, and return the rest in a
Constraints
- sentence will contain between 1 and 50 characters, inclusive.
- Each character in sentence will be an uppercase or lowercase letter (A-Z, a-z), or a space.
- sentence will not contain two consecutive spaces; that is, there will be exactly one space between words.
- sentence will not begin or end with a space.
"Hawaii is an island"
Returns: { "Hawaii", "an" }
's' is not a valid letter in Hawaiian, so "is" and "island" cannot be Hawaiian words.
"Mauna Kea and Mauna Koa are two mountains"
Returns: { "Mauna", "Kea", "Mauna", "Koa" }
"Lanai Kawai Molokai"
Returns: { "Lanai", "Kawai", "Molokai" }
"a e i o u are vowels"
Returns: { "a", "e", "i", "o", "u" }
"hello world"
Returns: { "hello" }
Submissions are judged against all 32 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Hawaiian with a public method vector<string> getWords(string sentence) · 32 test cases · 2 s / 256 MB per case