A higher resolution is required to access the IDE
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
Help J. K. Rowling in her writing. Indeed, Hagrid has a distinctive way of speaking.Apply letter and word transformations
The final letter of each word is replaced by
The first letter of each word is replaced by
The transformation should only take place if the word is longer than two characters.
The word
The word
The word
The word
Word replacements are applied regardless of case. Letter transformations do not apply to words already modified by word replacements.
You have to be careful to modify only Hagrid's sentences.
A sentence is considered to be spoken by
For example :
✅"You going to the forest?" Asked Hagrid. => Hagrid is the speaker in this sentence because he is mentioned outside the quotation marks.
❌"No it's ok Hagrid. I just want to reach the castle before lunch." Replied Harry fearfully. =>
Only the standalone word
❌ McHagrid
❌ Hagride
❌ hagrid
✅ Hagrid
Punctuation must not be altered.
Words consist of consecutive English letters. Leading or trailing punctuation is not considered part of the word.
If a word contains an apostrophe (
Take care of the letter case.
The transformation must preserve the original case pattern. If the replacement is longer than the original word, any extra letters inherit the case of the last original letter.
For example:
YoU => YeH
going => goin'
TO => TER
mE => mEH
Hello => 'ello
Input
Line 1 : An integer N for the number of lines.
N next lines : The lines to transform (each a line).
N next lines : The lines to transform (each a line).
Output
N lines : The lines transformed.
Constraints
1 ≤ N ≤ 20
1 ≤ length of line ≤ 150
line contains either 0 or 2" .
1 ≤ length of line ≤ 150
line contains either 0 or 2
Example
Input
2 "You going to the forest?" Asked Hagrid. "No it's ok Hagrid. I just want to reach the castle before lunch." Replied Harry fearfully.
Output
"Yeh goin' ter the fores'?" Asked Hagrid. "No it's ok Hagrid. I just want to reach the castle before lunch." Replied Harry fearfully.
A higher resolution is required to access the IDE