#K49177. Unique Word Lengths in Sentences
Unique Word Lengths in Sentences
Unique Word Lengths in Sentences
You are given n sentences. For each sentence, extract the words in the order they appear and output each word in the format word(length)
, where length
is the number of characters in the word. Only the first occurrence of the word (case-insensitive) in each sentence should be processed. Words differing only in letter case are considered the same, but the output should preserve the original case of the word.
For example, given the sentence "Alice loves reading books", the output is:
Alice(5) loves(5) reading(7) books(5)
The input is read from standard input (stdin) and the output is printed to standard output (stdout).
Note: Each sentence is processed independently.
inputFormat
The first line contains a single integer n, denoting the number of sentences. Each of the following n lines contains one sentence.
For instance:
3 Alice loves reading books Chaos and order are not exclusive Marie reads literary works every day
outputFormat
Output the processed words of each sentence in the order they appear, one per line.
For the sample input above, the output should be:
Alice(5) loves(5) reading(7) books(5) Chaos(5) and(3) order(5) are(3) not(3) exclusive(9) Marie(5) reads(5) literary(8) works(5) every(5) day(3)## sample
3
Alice loves reading books
Chaos and order are not exclusive
Marie reads literary works every day
Alice(5)
loves(5)
reading(7)
books(5)
Chaos(5)
and(3)
order(5)
are(3)
not(3)
exclusive(9)
Marie(5)
reads(5)
literary(8)
works(5)
every(5)
day(3)
</p>