Word in consecutive lines X25356


Statement
 

pdf   zip

html

Write a program that finds the first word appearing in two consecutive lines of a given text.

Input

The program reads a text composed of lines, maybe verses of a poem.

Output

The program outputs "Found: " followed by a word such that there are two consecutive lines that contain that word, no earlier pair of consecutive lines has a common word, and the appearance in the second line is as early as possible; or "Found nothing" in case such a word does not exist.

Public test cases
  • Input

    hi there
    hello there

    Output

    Found: there
    
  • Input

    as an unperfect actor on the stage
    who with his fear is put beside his part
    or some fierce thing replete with too much rage
    whose strengths abundance weakens his own heart
    so i for fear of trust forget to say
    the perfect ceremony of loves rite

    Output

    Found: with
    
  • Input

    word and occurs early
    there is a yes in this line of this text
    and yes also in this line we can see it
    and a yes occurs also in this line

    Output

    Found: yes
    
  • Input

    shall I compare thee to a summers day
    thou art more lovely and more temperate
    rough winds do shake the darling buds of may
    and summers lease hath all too short a date

    Output

    Found nothing
    
  • Input

    hello there world

    Output

    Found nothing
    
  • Input

    hello
    hi
    there hello
    hello there

    Output

    Found: hello
    
  • Information
    Author
    J L Balcázar
    Language
    English
    Official solutions
    Python
    User solutions
    Haskell Python