CCC '03 S2 - Poetry

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
Canadian Computing Competition: 2003 Stage 1, Junior #4, Senior #2

A simple poem consists of one or more four-line verses. Each line consists of one or more words consisting of upper or lowercase letters, or a combination of both upper and lowercase letters. Adjacent words on a line are separated by a single space.

We define the last syllable of a word to be the sequence of letters from the last vowel (a, e, i, o, or u, but not y) to the end of the word. If a word has no vowel, then the last syllable is the word itself. We say that two lines rhyme if their last syllables are the same, ignoring case.

You are to classify the form of rhyme in each verse. The form of rhyme can be perfect, even, cross, shell, or free:

  • perfect rhyme: the four lines in the verse all rhyme
  • even rhyme: the first two lines rhyme and the last two lines rhyme
  • cross rhyme: the first and third lines rhyme, as do the second and fourth
  • shell rhyme: the first and fourth lines rhyme, as do the second and third
  • free rhyme: any form that is not perfect, even, cross, or shell.

The first line of the input file contains an integer NN, the number of verses in the poem, 1 \le N \le 51 \le N \le 5. The following 4N4N lines of the input file contain the lines of the poem. Each line contains at most 8080 letters of the alphabet and spaces as described above.

The output should have NN lines. For each verse of the poem there should be a single line containing one of the words perfect, even, cross, shell, or free describing the form of rhyme in that verse.

Sample Input 1

One plus one is small
one hundred plus one is not
you might be very tall
but summer is not

Output for Sample Input 1


Sample Input 2

I say to you boo
You say boohoo
I cry too
It is too much foo
Your teacher has to mark
and mark and mark and teach
To do well on this contest you have to reach
for everything with a lark

Output for Sample Input 2


Sample Input 3

It seems though
that without some dough
creating such a bash
is a weighty in terms of cash
But how I see
the problem so fair
is to write subtle verse
with hardly a rhyme

Output for Sample Input 3



  • 0
    Badmode  commented on Jan. 24, 2021, 6:44 p.m.

    Stuck on the last test case but then I realized there are uppercase letters.

    • 2
      Dav_Did  commented on Jan. 24, 2021, 8:29 p.m.

      Yeah if you read other people's comment below you would save a lot of time.

  • 9
    Dav_Did  commented on Jan. 24, 2021, 3:01 p.m. edited

    Roses are red.

    Violet are blue.

    This question is so hard.

    That it turned my brain glue.

    • 4
      Summation  commented on Aug. 9, 2021, 11:33 a.m.

      The output should be "free" for this case.

    • -5
      jonathangong2005  commented on Jan. 24, 2021, 3:02 p.m.

      This comment is hidden due to too much negative feedback. Click here to view it.

  • 1
    Yourdeath9111  commented on June 25, 2020, 2:04 a.m.

    Can someone please tell me whats wrong with my code and why I keep getting out of bounds exception on cases 2 and 4... I have read over my code multiple times and I don't see ANYTHING that could cause the error. Any help is appreciated.

  • 1
    forgetUserName  commented on March 31, 2020, 12:56 a.m.

    the case 3 isn't correct for my code (and I've even tried different combination of codes but still don't know what the correct answer is) Can any one help me with that?

  • 0
    evanwild  commented on Jan. 17, 2019, 8:40 p.m.

    Test cases #2 and #4 aren't correct for me, any ideas?

    • 4
      NewAccount  commented on Aug. 1, 2019, 9:43 p.m. edit 2

      Make sure that the last syllable is in the last word in each line.

      For Example: the last syllable of the line "Helloh mjk" is "mjk", not "oh".

  • 1
    Relativity  commented on Nov. 7, 2017, 9:21 a.m.

    Anybody know why I'm getting a java.nullPointerException? It seems to be outputting the right thing.

  • 2
    Selena_Liu  commented on July 4, 2017, 9:10 p.m.

    last case... I'm using .lower() for the last syllable so that shouldn't matter...

  • 3
    susheelk  commented on Nov. 25, 2015, 10:11 p.m.

    Any suggestions for the last test case?

    • 4
      wsl1998  commented on Feb. 17, 2016, 11:12 a.m.

      Read the question. "Each line consists of one or more words consisting of upper or lower case letters, or a combination of both upper and lower case letters. "

  • 0
    BMP  commented on Jan. 6, 2015, 6:30 p.m.

    java .lastIndexOf(), is screwing me over.

    • 4
      FatalEagle  commented on Jan. 6, 2015, 7:00 p.m.

      Using java is screwing me over.


      • 0
        BMP  commented on Jan. 12, 2015, 11:13 a.m.

        What if, first, second and third rhyme and the fourth one does not. Will this be considered free?

        • 4
          Evan  commented on May 26, 2019, 11:59 a.m.

          yes, it will be considered free