CCC '15 J2 - Happy or Sad

View as PDF

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

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
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 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, 2019, 3:53 p.m.

welcome to the world of CCC

• 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

• commented on Feb. 10, 2017, 4:06 p.m.

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"

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

Fixed, thanks!

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

This comment is hidden due to too much negative feedback. Click here to view it.

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

• commented on Sept. 23, 2015, 1:20 p.m. edit 2

This comment is hidden due to too much negative feedback. Click here to view it.