First equal length words X43690


Statement
 

pdf   zip

html

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".

Input The input is a sequence of words.

Output The output is the first pair of words with the same length.

Observations You can import and use read from module jutge (or easyinput), but DO NOT import or use read_line.

Public test cases
  • 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
    
  • Information
    Author
    ProAl
    Language
    English
    Official solutions
    Python
    User solutions
    Python