Problem J
Compound Words
Write a program that reads a list of words from standard input and prints out a sorted list of all unique compound words that can be made by concatenating two different words from the input list. If the same compound word can be formed more than one way, it should only be listed once in the output.
Input
Input is a list of $1$ to $100$ words separated by whitespace (spaces and / or newlines). There may be more than one word on each input line. Each word is a sequence of at most $10$ lowercase English letters (a–z). Input ends at end of file.
Output
Your program should print out all unique compound words, one per line. They should be printed in sorted (dictionary) order.
Sample Input 1 | Sample Output 1 |
---|---|
a bb ab b |
aab ab aba abb abbb ba bab bba bbab bbb |