## CCC '15 J2 - Happy or Sad

View as PDF

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 and 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

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

• 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(:-()...

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

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

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

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

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

• 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?

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

what does IR mean as an error

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

Can anyone tell me why my code gets a WA?

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

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

Ok thanks!

• 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

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

• 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);

• commented on May 26, 2020, 3:41 p.m.

Thanks!

• 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 :-(

• commented on April 13, 2021, 5:53 p.m. edited

When you make it output the specified word, be careful not to do:

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

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

welcome to the world of CCC

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

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

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