Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Problem 920. Eliminate Polysyllabics: Long live short words!

Created by Ned Gulley

Given a string s1, return s2 in which all the words with more than one syllable have been removed.

To make things simple, we will (for the purposes of this problem) define a polysyllabic word as one in which at least two vowel groups are separated by a least one consonant group. Consider vowels to come from the set [aeiouy]. All other letters are considered consonants. There are many exceptions to the rules I have defined here, but I will keep the test suite consistent with these rules.

So these words are polysyllabic:

 ANY BUSY POLICEMAN EXPECTS COUNTLESS INTERRUPTIONS

These words are monosyllabic:

 STRENGTH IS THE SUM OF ALL WE KNOW TO BE TRUE

Here are some examples of one-syllable words that I WON'T use because they violate my rules:

 ONE ICED JUICE PLEASE

After you have removed the offending words, de-dupe the spaces. That is, any remaining words should be separated by exactly one space. There should be no spaces at the beginning or end of the output string s2. Letters may be upper or lower case.

Example:

 Input:  'The all day meetings will continue until we learn why productivity is so low'
 Output: 'The all day will we learn why is so low'

Tags

Problem Group

Solution Statistics

12 correct solutions 10 incorrect solutions
Last solution submitted on Aug 25, 2014

Problem Comments