#K79482. k-Spaced Words
k-Spaced Words
k-Spaced Words
This problem requires you to transform an input string by altering the spacing in each word. For each word in the string, determine its position k (where the first word is position 1, the second is 2, and so on), then insert exactly min(k-1, word_length-1)
spaces between every two consecutive characters of that word. The transformed words are then joined together with a single space. If the input string is empty, the output should also be an empty string.
Note: For each word, if the position-based spacing exceeds the available gaps (i.e. when k - 1 is greater than the number of gaps), use the maximum number of gaps available. All formulas are presented in LaTeX format, for instance, the number of spaces inserted is \(\min(k-1, \text{len(word)}-1)\).
inputFormat
The input is read from stdin and consists of a single line containing a series of words separated by single spaces.
outputFormat
The output is printed to stdout as a single line representing the transformed string after inserting appropriate spaces between characters as described above.
## samplehello
hello