Those Lengthy Words

Write a program that reads a sequence of words, creates groups of words with the same length, and prints the group with longer words. Groups of just one word are not considered.

For instance, the sequence: cat mouse dog fly crocodile bat horse contains a group of one word with 9 letters (crocodile), a group of 2 words of length 5 (mouse,horse), and a group of four 3-letter words (cat,dog,fly,bat).
Thus, the output must be mouse horse, since it is the group (with more than one word) that contains longer words.

If no groups with more than one word are found, the program output must be "All words have different lengths".

Input

The input is a sequence of words.

Output

The output is the group of equal-length words which are longer than words in any other group, discarding groups of size 1.

Problem information

Author: ProAl

Generation: 2026-01-25T17:25:25.259Z

© Jutge.org, 2006–2026.
https://jutge.org