CCC '15 J2 - Happy or Sad

View as PDF

Submit solution


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

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

We often include emoticons in our text messages to indicate how we are feeling. The three consecutive characters :-) indicate a happy face and the three consecutive characters :-( indicate a sad face. Write a program to determine the overall mood of a message.

Input Specification

There will be one line of input that contains between 1 and 255 characters.

Output Specification

The output is determined by the following rules:

  • If the input line does not contain any happy or sad emoticons, output none.
  • Otherwise, if the input line contains an equal number of happy and sad emoticons, output unsure.
  • Otherwise, if the input line contains more happy than sad emoticons, output happy.
  • Otherwise, if the input line contains more sad than happy emoticons, output sad.

Sample Input 1

How are you :-) doing :-( today :-)?

Output for Sample Input 1

happy

Sample Input 2

:)

Output for Sample Input 2

none

Sample Input 3

This :-(is str :-(:-a(nge te:-)xt.

Output for Sample Input 3

sad

Comments


  • 0
    absoluteIdiot  commented on Jan. 28, 2023, 11:48 p.m.

    Glad im using Python; .count makes this really easy


  • -1
    boshvix  commented on Nov. 10, 2022, 6:44 p.m.

    Another nice one


  • 0
    fedpanoz  commented on Sept. 24, 2022, 7:39 a.m.

    I can't find where my submission's bug.Any help?


  • 0
    EeveeCS  commented on Sept. 23, 2022, 5:28 p.m.

    what's wrong with my code? Nothing seems wrong.


    • -2
      vishanell  commented on Sept. 28, 2022, 7:27 p.m.

      Check your operators, that's where your bugs are.


  • -1
    960t  commented on Sept. 21, 2022, 8:58 p.m. edit 2

    this looks like something out of a generic analogue horror film


  • -1
    UnoTheCard  commented on July 23, 2022, 9:17 a.m.

    Please help I don't know what's wrong with my code :-(


  • 0
    Nickthew  commented on July 14, 2022, 3:06 a.m.

    I was pretty happy(:-)) I managed to finally get this to work, then I looked at some of the other submissions and made myself sad(:-()...


  • -1
    jonathansun  commented on Feb. 7, 2022, 3:33 p.m.

    Keep in mind escape characters if you are using java. Tip of advice lol


    • -5
      Jamkis9921  commented on Feb. 7, 2022, 4:53 p.m.

      This comment is hidden due to too much negative feedback. Show it anyway.


  • 0
    neo_coder  commented on Nov. 19, 2021, 2:22 a.m.

    I don't get where I am making a mistake, it seems to me I covered all possible cases. Any tip will be appreciated.


    • 0
      uselessleaf  commented on Nov. 19, 2021, 10:24 a.m.

      You can try the case :) or aaaaaaaaaaaaaaa

      Hopefully by trying these cases, you'll see that something is wrong with your if statement on line 5 🤔

      In case you're still struggling, remember to check on either side of an or in an if statement - is if happy or sad in message really checking what you think it is?


  • 0
    0Power10  commented on July 12, 2021, 9:28 p.m.

    what does IR mean as an error


  • 1
    mahes0640  commented on Feb. 7, 2021, 1:32 p.m.

    Can anyone tell me why my code gets a WA?


    • 3
      BamTargetShock_Java  commented on Feb. 7, 2021, 2:48 p.m.

      Python's "in" operator only checks if a substring appears in a string, and not how times it appears in the string. So for example, :-):-):-) is one word that contains three happy faces, but your code would read it as one happy face.


      • 3
        mahes0640  commented on Feb. 12, 2021, 2:20 p.m.

        Ok thanks!


  • 16
    cyopotatoe  commented on June 12, 2020, 5:10 p.m. edited

    Well determine the tone of this! :-I

    This is not me being stupid and not reading the instructions, it's a bad attempt at humor


  • 1
    Frontear  commented on Nov. 22, 2019, 9:28 a.m.

    I'm a bit unsure as to why my solution isn't working as intended. I've tried some of my personal test cases, and they work fine, but I can't seem to pass most of the test cases.


    • 6
      Dingledooper  commented on Nov. 22, 2019, 7:10 p.m. edit 2

      cin >> input won't get the entire line, just until the first space. It's better to use getline(cin, input);


  • 17
    Zanger  commented on March 22, 2019, 1:45 a.m.

    I just spend 20 minutes trying to find any small error in my code despite this being a low difficulty question just to find that I wrote an output as "unhappy" instead of "sad"... fml :-(


    • -7
      GamerWolf67  commented on April 13, 2021, 5:53 p.m. edit 2

      This comment is hidden due to too much negative feedback. Show it anyway.


      • 3
        henrybaolol9  commented on April 13, 2021, 7:12 p.m. edited

        the comment was on march 22, 2019 and that was the point of it. he exchanged sad with unhappy. ;-;


    • 10
      slowmomoe  commented on April 13, 2019, 3:53 p.m.

      welcome to the world of CCC


  • -41
    AliSatec  commented on Jan. 11, 2017, 3:09 p.m. edited

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 1
      Jaffy  commented on March 12, 2022, 7:48 p.m.

      read the question before asking


    • 8
      Kirito  commented on Jan. 11, 2017, 3:17 p.m.

      There will be one line of input that contains between 1 and 255 characters.

      This will not happen.