9
\$\begingroup\$

Introduction

Ever heard of Remind? No? Neither did I until about 2 years ago. Basic premise of it is for teachers to send out reminders and communicate with their students. Pretty neat, right? It even allows you send emotes and react to messages! Which I do on a daily basis.

But, one thing about Remind is that the teachers always send the "Do your homework!" "If you don't, you'll get an F!". But, there is useful stuff too, like "Test on Tuesday", or the occasional "Have a good day!". I almost always reply happy with a thumbs up, but sometimes, I have to put a thumbs down.

Challenge

Your task today is to find out if a message has a certain connotation to it. If it has a positive connotation to it, reply with a thumbs up. If it has a negative connotation, reply with a thumbs down.

How am I supposed to detect connotations?

A positive connotation will normally have 3 words in it. The 3 words are: Happy, Good, and Passed.

A negative connotation will have 3 also. Those 3: Test, Fail, and Homework.

What am I testing for?

You are testing to see if a message contains positive, negative or both connotations.

If a message has positive connotations to it, go ahead and return the unicode code point for thumbs up (U+1F44D).

If it has negative connotations to it, return the unicode code point for thumbs down (U+1F44E).

If the message has both negative and positive connotations, return the code point for a neutral face (U+1F610).

If, for some other reason, it doesn't have either connotations, return a nice ol' shrug (¯\_(ツ)_/¯). If the shrug doesn't show up right, here's the Emojipedia link to the shrug

Constraints

  • Program must take a message as input.
  • Positive connotations must return thumbs up code point (U+1F44D)
  • Negative connotations must return thumbs down code point (U+1F44E).
  • If the message has both connotations, return the neutral face code point (U+1F610).
  • If the message has neither connotations, return the shrug (¯\_(ツ)_/¯).
  • This is , Shortest bytes win

Test cases.

Input -> Output
Happy Good Friday! -> U+1F44D
Congrats, you just played yourself -> ¯\_(ツ)_/¯
You failed the test. -> U+1F44E
Good job on the test. -> U+1F610
\$\endgroup\$
  • \$\begingroup\$ You need to escape it \$\endgroup\$ – Rod May 26 '17 at 17:43
  • \$\begingroup\$ it's fine, the test case has the full shrug \$\endgroup\$ – KuanHulio May 26 '17 at 17:43
  • 1
    \$\begingroup\$ "If the message has both connotations, return the neutral face code point (U+1F610)." And no, not case sensitive. \$\endgroup\$ – KuanHulio May 26 '17 at 17:47
  • \$\begingroup\$ To clarify: if the string contains both types of words, return neutral, regardless of if there is more of one type than the other? \$\endgroup\$ – Shaggy May 26 '17 at 17:56
  • \$\begingroup\$ @Shaggy yes, just return neutral \$\endgroup\$ – KuanHulio May 26 '17 at 17:57
2
\$\begingroup\$

Python 3, 182 166 159 151 bytes

c=input().lower().count
print((["¯\_(ツ)_/¯"]+list("👍👎😐"))[any(map(c,["good","happy","passed"]))+any(map(c,["fail","test","homework"]))*2])

Try it online!

\$\endgroup\$
  • \$\begingroup\$ you can insert both anys inside the print : d[any(<positive>)+any(<negative>)*2] \$\endgroup\$ – Rod May 26 '17 at 17:45
  • 1
    \$\begingroup\$ I get 182 UTF-8 bytes instead of 169 \$\endgroup\$ – Cows quack May 26 '17 at 17:45
  • \$\begingroup\$ utf always makes me forget extra bytes, I usually just use python's len() function on my code. Will edit \$\endgroup\$ – Martmists May 26 '17 at 17:47
  • \$\begingroup\$ "👍👎😐" works fine for me. what version of python are you on? \$\endgroup\$ – Martmists May 26 '17 at 17:54
  • \$\begingroup\$ I haven't tested it, but I think you could do print(d[("good"in m or"happy"in m or"passed"in m)+("bad"in m or"test"in m or"homework"in m)*2]) instead \$\endgroup\$ – DJMcMayhem May 26 '17 at 17:57
0
\$\begingroup\$

JavaScript, UTF-8 encoded, 100 bytes

s=>['¯\_(ツ)_/¯',...'👎👍😐'][2*/happy|good|passed/i.test(s)+/test|fail|homework/i.test(s)]

Test cases:

const a =
s=>['¯\_(ツ)_/¯',...'👎👍😐'][2*/happy|good|passed/i.test(s)+/test|fail|homework/i.test(s)]

console.log(a('Happy Good Friday!'));
console.log(a('Congrats, you just played yourself'));
console.log(a('You failed the test.'));
console.log(a('Good job on the test.'));

\$\endgroup\$
0
\$\begingroup\$

Powershell, 190 bytes

"$($s=Read-host;"$s ->";$1=("Test","Fail","Homework"|?{$s-match$_});$2=("Happy","Good","Passed"|?{$s-match$_});if($1-and$2){"😐"}elseif($1){"👎"}elseif($2){"👍"}else{"¯\_(ツ)_/¯"})"

Displays the input and output next to eachother.

Happy Good Friday! -> 👍

Congrats, you just played yourself -> ¯\_(ツ)_/¯

You failed the test. -> 👎

Good job on the test. -> 😐

\$\endgroup\$
0
\$\begingroup\$

PowerShell, 187 bytes

read-host|%{$s=$_;$f=0;0..5|?{$s.indexof((-split'Happy Good Passed Test Fail Homework')[$_],0,$s.length,3)+1}|%{$f=$f-bor(1,2)[$_/3]};$s+' -> '+('¯\_(ツ)_/¯','👍','👎','😐')[$f]}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.