Wordy Lines X32891


Statement
 

pdf   zip

html

Write a program that finds, among the lines of a text, the earliest one that is more “wordy” than the very first one, that is, has strictly more words.

Input

Input is a text on standard input stdin that consists of a number of lines, but at least one line. Lines consist of words, separated by one or more spaces; words are nonempty sequences of letters.

Observe that lines may contain no words (even the very first line may contain no words).

Output

If there is any line in the text that has strictly more words than the first line of the text, print the earliest such line; otherwise, print “The wordiest line in the text is the first one:” followed, in the subsequent line, by the first line of the text.

Public test cases
  • Input

    This is the first line and contains nine words
    Then other lines come along
    Some are shorter than others and some longer
    Some have nine words like the first line had
    One is short
    This has more than nine words and becomes the output
    Other short lines may come along
    Even other long lines with way more than nine words but they show up too late
    

    Output

    This has more than nine words and becomes the output
    
    
  • Input

    Yep
    Notice that we left the first line empty
    Then the first nonempty line already has more than zero words
    

    Output

    Yep
    
    
  • Input

    Although this line is not too wordy
    all   the   others
       are not wordy    enough
    and   no one  of them reaches  beyond
     the seven words  of the first       line
    

    Output

    The wordiest line in the text is the first one:
    Although this line is not too wordy
    
    
  • Information
    Author
    José Luis Balcázar
    Language
    English
    Official solutions
    Python
    User solutions
    Python