CCC '15 J2 - Happy or Sad

View as PDF

Submit solution


Points: 3 (partial)
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
    ValVal  commented on Jan. 20, 2025, 12:45 a.m. edited

    i suck at java! can anyone help!!


    • 0
      Allan5621132  commented on Aug. 11, 2025, 5:45 p.m.

      i saw your submission to this problem in python3, it mostly is because you put the if statement of if happy = sad, however this would print unsure when it was supposed to print none, so maybe detection for none before unsure https://dmoj.ca/submission/6897481


  • -2
    Jobanana  commented on Jan. 14, 2025, 2:13 p.m.

    Hint:

    Please use simple way to think the question. It's not difficulty. You can make two variable separate to put about Happy (=W.count(":-)")) and Sad (=W.count(":-(")) ,and start judgement if Happy (> || < || ==) Sad

  • -5
    aimalie98  commented on Oct. 25, 2023, 5:56 p.m. edited

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


    • -5
      JoeP  commented on Nov. 19, 2023, 12:26 p.m. edit 2

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


    • -7
      JoeP  commented on Nov. 19, 2023, 12:17 p.m. edit 2

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


      • -5
        Daquine  commented on Dec. 14, 2023, 9:57 p.m. edited

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


        • -3
          曲意  commented on April 3, 2024, 11:50 a.m. edit 2

          I think the right answer is this:

          n1 = a.count(":-)")
          n2 = a.count(":-(")
          
          if n1 + n2 != 0:
          

          • 0
            别放弃  commented on Feb. 12, 2025, 1:11 a.m.

            天才,多谢你的启发性思考,祝新年快乐