CCC '02 J2 - AmeriCanadian

View as PDF

Submit solution

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

Problem type
Canadian Computing Competition: 2002 Stage 1, Junior #2

Americans spell differently from Canadians. Americans write neighbor and color while Canadians write neighbour and colour. Write a program to help Americans translate to Canadian.

Your program should interact with the user in the following way. The user should type a word (not to exceed 64 letters) and if the word appears to use American spelling, the program should echo the Canadian spelling for the same word. If the word does not appear to use American spelling, it should be output without change. When the user types quit! the program should terminate.

The rules for detecting American spelling are quite naive: If the word has more than four letters and has a suffix consisting of a consonant followed by or, you may assume it is an American spelling, and that the equivalent Canadian spelling replaces the or by our. Note: you should treat the letter y as a vowel.

Sample Input

color
for
taylor
quit!

Sample Output

colour
for
taylour

Comments


  • 0
    Gilgamesh_101  commented on Sept. 19, 2022, 2:18 a.m.

    I had mine first try, but was printing 'quit!' along side my output

    don't do that! I was very confused.


  • -2
    Berton  commented on Aug. 24, 2022, 10:22 p.m.

    Only 1 test case???


  • 0
    ducws  commented on June 19, 2022, 5:49 a.m. edit 2

    instructor -> instructour (I'm not English native and based on my knowledge it doesn't exist 'instructour' word) but my answer is still accepted. If anyone can explain it that would be great. Thanks


    • 2
      Tofer_G  commented on June 20, 2022, 11:22 a.m.

      Instructour is not actually a word.

      "The rules for detecting American spelling are quite naïve:"

      The program does not actually detect if words are real words. After all, you could potentially have a word 64 letters long. It is just detecting a sequence, and making the changes. So in this instance, correct answers are not necessarily real words. I hope that make sense for you.

      Now if you see this, try and answer my question below please :D


  • 0
    Tofer_G  commented on June 17, 2022, 7:11 p.m.

    Whenever I test 4 letter words, or words that are longer than four letters but do not end in "or", I have an extra space of line under that output. I don't understand why this is happening. I would like to know if this is preventing me from solving this problem, or if there is something else wrong with my code. Any help would be appreciated.


  • 0
    CS7  commented on May 21, 2022, 3:59 p.m.

    Can someone please tell me where I am going wrong. It seems to work fine in Jupyter, but I must be missing a test case.


  • -1
    xiaodre  commented on March 30, 2022, 8:42 p.m.

    i'm so confused to why my outputs "clip". Are the strings present in the error the test cases which i failed?

    I don't need the solution, just someone to explain what's wrong in the logic of my code

    Halp plox :(


    • 2
      Badmode  commented on March 30, 2022, 11:21 p.m.

      First off, your program should repeatedly prompt inputs until you recieve "quit!"

      Secondly, DMOJ only shows the first 50 characters of your output to prevent users from dumping input data for hardcoding. Your 50 characters are clipped (attached) to that testcase for you to view.

      Finally, join the DMOJ discord! Asking for help there will result in faster responses and avoids cluttering up the comments section.


      • 0
        xiaodre  commented on April 5, 2022, 6:45 p.m.

        I have procceded with my readings and have finally understood what u meant and how to do it, regarding the "your program should repeatedly prompt inputs until you recieve "quit!". Tho, i have updated my code so its more readable and shorter but i still get the same error.

        Finally, i have entered the discord, thanks a lot!!! I'll try not to be too annoying for the people there :)


  • -1
    TriPoloski  commented on Feb. 5, 2022, 1:40 a.m.

    What am I doing wrong?, all my inputs seem to be converting to Canadian correctly.


    • 0
      Spitfire720  commented on Feb. 5, 2022, 10:22 a.m.

      You forgot to print the words that don't need to be translated to Canadian.


      • 0
        TriPoloski  commented on Feb. 5, 2022, 12:07 p.m.

        lol its always the obvious things. Thanks.


  • 1
    breakWood  commented on Jan. 8, 2022, 4:21 a.m.

    Be careful, vowel+or still no need to change, like floor...


  • -1
    gale  commented on Dec. 30, 2021, 12:20 a.m. edited

    i am confused about my wrong answer, my question was writed at my code comment in my last upload, can someone check my answer and tell me why. Respected to the question creater, i can't describe my problem at here.


    • 3
      d  commented on Dec. 30, 2021, 3:14 p.m. edited

      For help with any questions about programming, ask in the DMOJ Discord. These chats are much more responsive than the DMOJ comments section.


  • -2
    MakerKaren  commented on Dec. 24, 2021, 2:05 p.m. edited

    For those that know American vs Canadian spellings, neighbor should become neighbour, but instructor should not become instructour. But according to the given rules, it should. Given the spelling/structure of those words, I'm not sure how to tell the program how to tell the difference.


    • 3
      Spitfire720  commented on Dec. 24, 2021, 3:10 p.m.

      I think you're too tripped over how American spelling really is. Pretend that this is the new way of American spelling; since it's a 3 pointer, they're not looking for anything complicated.


  • 3
    Harryg33107  commented on Aug. 28, 2019, 12:32 p.m.

    Can I assume the input is all lowercase letters?


  • -1
    Charles232  commented on Jan. 17, 2019, 9:19 p.m.

    What if the word has 2 "or"s???


    • 7
      magicalsoup  commented on Jan. 17, 2019, 9:34 p.m.

      it wont happen, according to the ccc test cases, but i believe the problem statement is clear enough


  • 3
    AmineHamoura03  commented on Feb. 26, 2018, 11:48 a.m.

    Can someone tell my please why it's WA ?!


    • 19
      Iamhussam  commented on Feb. 27, 2018, 5:59 p.m.

      your code searches for "or" anywhere in the word, while it should search for it only in the end. e.g : for input "order" your program outputs : "ourderr"