|
Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Ismail Shpati.
Swap largest word, reverse the rest
Question: A line of text will be given. You will have to do the following modifications to this line of text:
- Swap the largest word, with the smallest one (smallest word must have more than 2 characters; length > 2).
- If there are two or more words with the same length, take the first instance.
- Reverse the rest of the words that have more than 3 characaters (length > 3).
- There will be punctutation marks at the end of some words (" . " " , " " ! " " ? " " ; " " : "). They shouldn't be calculated in the length of the word.
- The punctuation mark should remain at the end of the word even if the word is reversed. (ex. word. => drow.)
Input specification: You will be given one line of text. (maximum length of the line 300 characters; maximum length of a word 20 characters)
Output specification: Show the modified line of text (Note: there shouldn't be a space at the end of the line)
Sample Input I
Andy went, to the park. |
Sample Input II
Scattering around, did not bring much joy. |
Sample Output I
the tnew, to Andy krap.
|
Sample Output II
did dnuora, Scattering not gnirb hcum joy.
|
Sample Input I Explanation: At the first input, we have 3 words with the length of 4 which also is the max length (Note: "went" and "park" both have a punctuation mark at the end but it isn't calculated in the length of the word). We take the first instance, which is "Andy" and swap it with "the" which is the smallest word with a length greater than 2. The rest of the words are reversed without moving the punctuation mark. (went, => tnew,)
Для отправки решений необходимо выполнить вход.
|