Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

How happy is this emoticon?

In this challenge, submissions will be programs or function which, when given an emoticon such as :-), :(, or :D, will rate their happiness from 0 to 3.

An emoticon will be one of the following:

  • :(: 0
  • :|: 1
  • :): 2
  • :D: 3

Emoticons may also have noses (a - after the :).

Test cases:

:( -> 0
:-| -> 1
:D -> 3
:-) -> 2
:| -> 1

This is a code golf challenge, shortest answer per language wins.

Answer*

Draft saved
Draft discarded
Cancel
4
  • \$\begingroup\$ 8 bytes \$\endgroup\$ Commented Apr 2, 2020 at 1:47
  • \$\begingroup\$ @Bubbler Unfortunately, it says the link can’t be decode; mind repasting? \$\endgroup\$ Commented Apr 2, 2020 at 3:02
  • \$\begingroup\$ @AviF.S. Here it is. Weird though, because I can open it fine on my PC. \$\endgroup\$ Commented Apr 2, 2020 at 3:22
  • \$\begingroup\$ Very odd! Still doesn’t work for me but I’m on the mobile app (iPhone). Though I couldn’t find anything on Meta re: bugs with TIO and mobile... Suppose I’ll just hold my excitement ‘til I can check on my computer :) \$\endgroup\$ Commented Apr 2, 2020 at 3:33

AltStyle によって変換されたページ (->オリジナル) /