Problem Statement
PROBLEM STATEMENT Two friends are attempting to speak so nobody around them can understand what they are talking about. They decide to speak in PigLatin to disguise their words. PigLatin words are created by transforming a normal word as follows: *Find the first vowel in the word. *Take all the letters before the first vowel, and move them at the end of the word. *Add the letters "ay" to the end of the word. The word "thank" would become ankthay because the first vowel is 'a', all letters before 'a' are "th", placed at the end would become "ankth", then add the "ay" to become "ankthay". Create a class PigLatin that contains the method transform, which takes in one parameter word, which is a string. This method returns the PigLatin transformation of a normal word. DEFINITION Class: PigLatin Method: transform Parameters: String Returns: String Method signature (be sure your method is public): String transform(String word); TopCoder will ensure the validity of the inputs. Inputs are valid if all of the following criteria are met: - All characters in word are lowercase letters [a-z], with no spaces - word has length between 2 and 50 inclusive - word will contain at least one vowel between the first letter and the second to last letter inclusive NOTES: - regular vowels are considered to be 'a', 'e', 'i', 'o', 'u' - a regular consonant is considered to be all letters besides 'y' and regular vowels - 'y' is considered a consonant if it has a vowel for the next letter in the word - 'y' is considered a vowel if it has a consonant for the next letter in the word - if y is the last letter of the word, it is considered a consonant - if a word starts with a vowel, adding "ay" to the end of the word transforms it into PigLatin EXAMPLES 1) word = "thanks" Method returns "anksthay" 2) word = "yyyb" Method returns "yyybay" because the last 'y' in the word is considered a vowel since 'b' follows it, so the 'y' before it is considered a consonant, and the first 'y' is therefore considered a vowel. 3) word = "yyya" Method returns "yyayay" because the last y in the word is considered a consonant since 'a' follows it, so the 'y' before it is considered a vowel, and the first 'y' is therefore considered a consonant.
Definition
- Class:
- PigLatin
- Method:
- transform
- Parameters:
- String
- Returns:
- String
- Method signature:
- String transform(String param0)
- (be sure your method is public)
Constraints
Examples
No public sample cases were explicitly marked for this problem in the original data.