CCC '15 J2 - Happy or Sad

View as PDF

Submit solution



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

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


  • 4
    JohnWinter  commented on April 1, 2017, 4:05 p.m. edited

    Why am I getting RTE (write syscall disallowed) on the first test case? Edit: Never mind, figured it out


  • 1
    jpr4  commented on Feb. 10, 2017, 4:06 p.m.
    Spelling mistake?

    We often include emoticons in our text messages to indicate how we are feeling. The three con­ secutive 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.

    "Consecutive" in the first line is misspelled as "con secutive"


    • 0
      Kirito  commented on Feb. 10, 2017, 7:15 p.m.

      Fixed, thanks!


  • 0
    AliSatec  commented on Jan. 11, 2017, 3:09 p.m. edited
    string length

    What about strings longer than 255?


    • 0
      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.


  • 0
    jackyliao123  commented on Sept. 23, 2015, 1:20 p.m. edit 2
    nice question

    nice question, pretty good