First Frequent Over Limit X91546


Statement
 

pdf   zip

html

Write a program that reads a limit integer and a sequence of words and finds the first word in the sequence whose frequency count reaches beyond the limit.

Input

First comes a limit integer n; follows a sequence of nonempty words, all formed only by lower-case letters. Words are separated by blank spaces or line ends, or both; at least one such separator, but maybe more than one.

Output

If there are words in the sequence that appear more times than the limit n, the first one found to reach above the limit has to be identified with a message like in the examples. Otherwise, also as in the examples, the message "No words reach above frequency n" is to be printed.

Public test cases
  • Input

    3
    erre con erre guitarra erre con erre barril
    

    Output

    The first word to reach above frequency 3 is "erre".
    
  • Input

    3
    por esa puerta de elvira 
    sale muy gran cabalgada 
    cuanto del hidalgo moro 
    cuanta de la yegua baya 
    cuanta de la lanza en mano 
    cuanta de la adarga blanca
    
    

    Output

    The first word to reach above frequency 3 is "de".
    
  • Input

    100
    the p versus np problem is a major unsolved problem in computer science
    

    Output

    No words reach above frequency 100.
    
  • Input

    1
    the p versus np problem is a major unsolved problem in computer science
    

    Output

    The first word to reach above frequency 1 is "problem".
    
  • Information
    Author
    Language
    English
    Official solutions
    Python
    User solutions
    Python