Let's Portmanteau
Time limit5sMemory limit1024 MB
Given two words, build a portmanteau from the first word's leading consonants, one merging vowel, and the second word's trailing consonants, then print it.
- Level
Easy2 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
From "yourdictionary.com": Portmanteau, pronounced "port-man-tow," refers to a new word made from two words and their meanings. For example, the portmanteau brunch refers to a combined meal of breakfast and lunch, and spork is a mix between a spoon and a fork.
You are to combine two words using a simplified approach.
Rules for combining:
-
Get the first letter of the first word regardless of whether it is a vowel or a consonant. Then, starting from the second letter of the first word, get letters moving right until you reach a vowel. If no vowel is found while moving right, all letters are taken. If there is a vowel moving right, call it v1.
-
Get the last letter of the second word regardless of whether it is a vowel or a consonant. Then, starting from the letter just before the last letter of the second word, get letters moving left until you reach a vowel. If no vowel is found while moving left, all letters are taken. If there is a vowel moving left, call it v2.
-
Combine the two words by listing the letters taken from the first word (Step 1), then a vowel (the merging vowel), then the letters taken from the second word (Step 2). The merging vowel is chosen as follows:
- If the second word has a vowel moving left (that is, v2 exists), v2 is the merging vowel.
- If the second word has no vowel moving left (v2 does not exist) but the first word has a vowel moving right (v1 exists), v1 is the merging vowel.
- If neither v1 nor v2 exists, the letter "o" is the merging vowel.
Assume the vowels are "aeiou".
Input
There are two input lines. The first line gives the first word, and the second line gives the second word. Each word starts in column 1, has at least 4 and at most 20 letters, and contains only lowercase letters.
Output
Print the combined word on one line.