Write a program that reads a sequence of words, and locates the first two words with the same length. Note that the second element of this pair is the first word to appear with a length that has already been seen in some previous word in the sequence.
For instance, for sequence:
mouse dog crocodile bat horse the output must be
dog, bat, since it is the first pair of words with the same
length.
If no pair with the same length is found, the program output must be
"All words have different lengths".
The input is a sequence of words.
The output is the first pair of words with the same length.
Input
cat mouse dog fly crocodile bat horse
Output
cat dog
Input
bat mouse crocodrile elephant geko
Output
All words have different lengths
Input
mouse dog crocodile fly horse bat
Output
dog fly