1s, 512 MB
Given a long string of text, you will have to print it following these rules:
- Replace all consecutive spaces with a single space character.
- No line should be longer than 9 characters (including the newline character at the end) and should contain as many words as possible.
- You may start a newline only in between two words (replacing the space character between the words with a newline character).
- No line should begin or end with any other space character. In case there is a non-newline space character at the beginning or ending of a line, remove it.
- In case a word is longer than 8 characters, replace it with the word "#bigword".
The input contains a long string consisting of lowercase alphabets, spaces (' '). A word in the input string will not be longer than 20 characters.
Print the text following the rules.
january february march april may june july august september october november december