Hard
Fully Justified Text
Read a width w and a paragraph. Break it into lines greedily (as many words as fit, separated by single spaces). Then pad every line except the last with extra spaces between words so it is exactly w long, giving the leftmost gaps one more space when it doesn't divide evenly. A line with one word is left-aligned. The last line stays as it is.
Input
w, then one line.
Output
Lines.
Sample 1
Input
16 This is an example of text justification.
Output
This is an example of text justification.
Sample 2
Input
10 short
Output
short
Output appears here