Task
In this challenge, you will be given an string emoticon, and your task will be to output its happiness.
How?
An emoticon will always have eyes and mouth. It can also include eyebrows and nose. Each part will influence the overall happiness rating, which is the sum of happiness ratings of all parts. Emoticons may be flipped, reversing the order of parts. Here is the different possible parts and their happiness rating:
Symbol Flipped symbol Happiness rating
Eyebrows:
<None> <None> 0
< > -2
[ ] -1
| | 0
] [ 1
> < 2
Eyes:
: : 0
; ; 1
Noses:
^ ^ 0
- - 0
Mouth
< > -3
( ) -2
[ ] -1
| | 0
] [ 1
) ( 2
> < 3
Test cases:
In Out
:) 2
<:( -4
|:-| 0
>;^) 5
(; 3
>-:< -1
(:| 2
Rules
- You must be able to handle flipped emoticons. If the input can be interpreted both ways (for example <:<) you can output either of the possible results
- Standard loopholes and I/O rules apply.
- This is code-golf, so shortest code wins.
>:<
is not strictly palindromic, but rather symetrical.>:>
would be palindromic. Note that if you meant symetrical, the result will be the same, considered as a flipped one or not. But for palindromic ones the result will be different (opposite) \$\endgroup\$^-
based on the test cases?), because it does influence the positions. I.e.>^:>
will only have a single possible output of-1
(2 for eyebrow>
, 0 for eyes:
, -3 for mouth>
), because we know the nose is between the mouth and eyes. Unlike>:>
which doesn't have a nose, and therefore can have two possible outputs depending on which>
we count as mouth/eyebrows respectively. \$\endgroup\$