[Question]
  [
[OG post](https://codegolf.stackexchange.com/questions/202894/how-happy-is-this-emoticon)
# 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
1. 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
2. Standard loopholes and I/O rules apply.
3. This is code-golf, so shortest code wins.
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~60~~ 59 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
„:;S¡D€gÆI„()SkàĀ-dUv">)]|"')NXQ×K©.ºDysÃk®g<-X·<*yĀ*}I';åO
```
[Try it online](https://tio.run/##AVsApP9vc2FiaWX//@KAnjo7U8KhROKCrGfDhknigJ4oKVNrw6DEgC1kVXYiPildfCInKU5YUcOXS8KpLsK6RHlzw4Nrwq5nPC1Ywrc8KnnEgCp9SSc7w6VP//8@LTo8) or [verify all test cases](https://tio.run/##yy9OTMpM/V9TVmmvpPCobZKCkn3l/0cN86ysgw8tdHnUtCb9cFslkK@hGZx9eMGRBt2U0DIlO83YGiV1Tb@IwMPTvQ@t1Du0y6Wy@HBz9qF16Ta6EYe222hVHmnQqq1Utz681P@/zn8rTS4bKw2uGivdGi476zhNLg1rLjtdKxsuDasaoAyXlR1Q2I7LxtoGAA).
**Explanation:**
```
„:;S              # Push string ":;", and convert it to a list of characters: [":",";"]
    ¡             # Split the (implicit) input-string on these characters
     D            # Duplicate the pair
      €g          # Get the length of each part
        Æ         # Reduce by subtracting
I                 # Push the input again
 „()S             # Push string "()", and convert it to a list of characters: ["(",")"]
     k            # Get the 0-based index of these characters in the string
                  # (or -1 if it isn't present)
      à           # Pop and push the maximum
       Ā          # Check that this is NOT 0 (0 if 0; 1 if -1, 1, 2, or 3)
-                 # Subtract the two from one another
 d                # Check that this is non-negative (>=0)
  U               # And pop and store this result in variable `X`
                  # (X=1 for faces where the mouth is left; X=0 for faces where the
                  # mouth is right or where we couldn't determine mouth/eyebrows)
v                 # Loop over the parts `y` in the pair we duplicated after the split:
 ">)]|"           #  Push string ">)]|"
         N        #  Push the 0-based loop-index
          XQ      #  Check if it's equal to variable `X` (1 if N==X, 0 if N!=X)
       ')   ×    '#  Repeat ")" that many times (")" if N==X, "" if N!=X)
             K    #  Remove that from string ">)]|"
              ©   #  Store this string in variable `®` (without popping)
               .º #  Mirror it with overlap: ">)]|"→">)]|[(<" or ">]|"→">]|[<"
 D                #  Duplicate this mirrored string
  y               #  Push the current part
   s              #  Swap so the copy of the mirrored string is at the top
    Ã             #  Keep only those characters in the part (removes noses "^"/"-")
     k            #  Get the 0-based index of the character in the mirrored string
      ®g          #  Push string `®`, and pop and push its length
        <         #  Decrease it by 1
         -        #  And subtract this from the index
 X                #  Push variable `X`
  ·               #  Double it
   <              #  Decrease it by 1
    *             #  And multiply the top two values
                  #  (negates the current value if X==0, or leaves it as is if X==1)
 y                #  Push the current part again
  Ā               #  Check that it's NOT empty (0 if empty; 1 otherwise)
   *              #  And multiply that as well, so empty parts become 0
}I                # After the loop, push the input again
  ';å            '# Check if it contains a ";" (1 if truthy; 0 if falsey)
O                 # And sum all values on the stack
                  # (after which the result is output implicitly) 
```
[Answer]
# JavaScript (ES6), ~~181~~ 176 bytes
```
s=>((/^[()]|[-^][:;]|[:;]$/.test(s)?s=[...s].reverse(q=-1):q=1,[b,e,n,m]=s,n?m?0:e<':'|e>';'?[e,b,m]=s:m=n:[e,m,b]=s,"<[|]>".indexOf(b)-2)%3+q*(e>':')+"<([|])>".indexOf(m)-3)*q
```
[Try it online!](https://tio.run/##ZY5NboMwEEb3PQWyWjGT2CaEdjNgOEIPYIEUEhOlCqZgFHXhu1Na0R@RzWhG73ua7@1wO7jjcHkfhe1OZmrU5FQOEFUasPRaVKWmdF7m8RjJ0bgRHBZOaSmlK@VgbmZwBnolYqRexVzX3HDL21I5bou22JHJQgq9ycM0LLTh9TejVlmar5bXX0mWaV/mTF7syXy8NlCj2ONTsu03MIsU4pZlMEfwX6ZFkeCmn46ddd3VyGt3hgYYIQsCxCCKgmD/sIIZAVugeF5DT8KzxdytYZ5W@ANf1hDSv5/JnSkoW0wR35nk2W/b6RM "JavaScript (Node.js) – Try It Online")
### Commented
```
s => (                      // s = smiley string
  (                         //
    /^[()]|[-^][:;]|[:;]$/  // the smiley is unambiguously flipped if:
                            //   - it starts with a parenthesis
                            //   - or there's a nose before the eyes
                            //   - or it ends with the eyes
    .test(s) ?              // if the smiley is flipped:
      s = [...s]            //   reverse s
          .reverse(q = -1)  //   and set q to -1
    :                       // else:
      q = 1,                //   set q to 1
    [b, e, n, m] = s,       // default order: eyebrows, eyes, nose, mouth
    n ?                     // if s is at least 3 character long:
      m ?                   //   if s is 4 character long:
        0                   //     we got it right, so do nothing
      :                     //   else (3 characters):
        e < ':' | e > ';' ? //     if there's a nose:
          [e, b, m] = s     //       new order: eyes, nose, mouth 
                            //       but we actually load the nose into the
                            //       eyebrows to invalidate them
        :                   //     else:
          m = n             //       the nose is actually the mouth
    :                       // else (2 characters):
      [e, m, b] = s,        //   new order: eyes, mouth
                            //   (and set eyebrows to undefined)
    "<[|]>".indexOf(b) - 2  // compute the score for the eyebrows
  ) % 3 +                   // turn -3 into 0
  q * (e > ':') +           // add the score for the eyes
  "<([|])>".indexOf(m) - 3  // add the score for the mouth
) * q                       // multiply the final result by q
```
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 165 bytes
```
$
@
([()].+|..[:;].|.+[:;])@
@$1
T`()><`Ro`@.|.@
T`(<[]>)`Ro`@.+
[[<(]
#$&
T`()<>[];`33221
\d
$*1@
1
@1
+`#@1
#1#
+`#1[^1]*@1|@1[^1]*#1
[^#1]
^(#)?(1#*)*
$#1$*-$#2
```
[Try it online!](https://tio.run/##JYq9CsIwFIX38xo3yk1KA7fd0hDv5i5uMSWCDi4K4ph3r60u5@877/vn8bwuOz7WxUDBmW3xXfM@h6n45rvNrUKN4FzZplhPr6or0a3HXJL9Lx1yjlxAZv97xpTLVMdxGASXG4wThUAFXaVVSWhLkmcpTqXpP5EAeSYpwMxkDyzkrIMhMa43NCxLsIiB0ULfkKbZgiekPkRwaCv5Ag "Retina 0.8.2 – Try It Online") Link includes test cases. Explanation:
```
$
@
```
Append a chin to the face.
```
([()].+|..[:;].|.+[:;])@
@$1
```
If the face seems flipped then prepend the chin instead.
```
T`()><`Ro`@.|.@
```
Switch `()`s and `><`s in the mouth, so that `><`s are scored consistently.
```
T`(<[]>)`Ro`@.+
```
Flip the characters in a flipped face.
```
[[<(]
#$&
```
Mark the unhappy characters.
```
T`()<>[];`33221
```
Get the happiness of each character.
```
\d
$*1@
```
Convert the happiness to unary.
```
1
@1
```
Initially mark the happiness as positive.
```
+`#@1
#1#
```
Propagate negative happiness.
```
+`#1[^1]*@1|@1[^1]*#1
```
Pair happiness and unhappiness and delete both.
```
[^#1]
```
Delete all other characters.
```
^(#)?(1#*)*
$#1$*-$#2
```
Calculate the total happiness.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 213 bytes
```
Association[Thread[{""<>#,""<>(Reverse@#/.(Rule@@@Characters@"<>><())([]]["~Partition~2))}&[StringTake[" <[|]>:; ^-<([|])>",List/@{##}+{0,6,8,11}]~StringDelete~" "]->If[#<2,4,#]+#2+#4-9]&@@@Tuples@Range@{6,2,3,7}]
```
[Try it online!](https://tio.run/##JY5fT4MwFMW/CmmTpR3FOVymltrUqA9LfFgYb02XNFgGkYGBzhf@fHUs@HLP/Z3ce3Ku2ubmqm2R6inzXqbXtq3TwnFdySRvjP6SHQCMQzJPFJtf07RGwM0dim@lEUK85brRqXW2cBecIYyRVEqC8agbW8xJY4jxsJIn2xTVJdHfRgKPyV5xGnnngCG3Yg7IZ9HajeggHPzunuzJE9luBzX@v72b0lgzAg@ogB8yCVlIdgQqH4Y@3AXPauW6JLef0rQi1tXFiG5PQvJAHgc1nVJdyaOLsWKdifVHmtdKdIBiQDzAKJqlp0E/K4/Oi42ihQLKFqI9GKLpDw "Wolfram Language (Mathematica) – Try It Online") This is an expression which evaluates to an `Association` object. It takes a string as input and returns an integer as output. The logic is very simple: it generates and rates all possible emoticons, and then it returns the rating for the given emoticon.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 56 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
O:6ṣ9Ẉ>/ȯḢƲ%5Ḣ
ṚÇ©¡“<[|]>“<([|])>”iⱮ€U2¦o3SḢḟ0_7N®¡+”;e$
```
**[Try it online!](https://tio.run/##y0rNyan8///hjsVGjxrmKGho6sY9apib@Wjjuoc7WuyMuR7unHW4/dDKQwuBsjbRNbF2IFoDyNC0g6p71LQm1OjQsnzj4Ic7Fj3cMd8g3tzv0LpDC7WB8tapKv///7fRtbYBAA "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##y0rNyan8///hjsVGjxrmKGho6sY9apib@Wjjuoc7WuyMuR7unHW4/dDKQwuBsjbRNbF2IFoDyNC0g6p71LQm1OjQsnzj4Ic7Fj3cMd8g3tzv0LpDC7WB8tapKv8f7t5yuB2oKPL/fytNLhsrDa4aK90aLjvrOE0uDWsuO10rGy4NqxoA "Jelly – Try It Online"). Or see [all the emoticons](https://tio.run/##y0rNyan8/9/fyuzhzsWWD3d12OmfWP9wx6Jjm1RNgRTXw52zDrcfWnlo4aOGOTbRNbF2IFoDyNAEsuZmPtq47lHTmlCjQ8vyjYOB6h/umG8Qb@53aN2hhdpAeetUlf/Wjxr3KSg83NloonO43ZsLqF8BZpCVNYinG4di5tFJBUBTgKY@atxmHapyuB3IjPz/HwA "Jelly – Try It Online").
### How?
This decides whether to reverse the string using the helper link (if the left of the eyes is longer than the right or if the string starts with a `(` or `)`, all using ordinals div six). Then finds the unflipped values of the eyebrows and mouth by indexing into two lists of characters while special-casing a lack of eyebrows and then offsetting the sum. Negates this result if we reversed the string (effectively the same as flipping the characters). Finally adds one to the result if the eyes are winking.
```
ṚÇ©¡“<[|]>“<([|])>”iⱮ€U2¦o3SḢḟ0_7N®¡+”;e$ - Main Link: list of characters, E
   ¡                                      - repeat...
 Ç                                        - ...number of times: call helper link as f(E)
  ©                                       -    (and copy the result to the register) 
Ṛ                                         - ...action: reverse
    “<[|]>“<([|])>”                       - list of lists of characters = ["<[|]>","<([|])>"]
                     €                    - for each (list, p, in that list):
                    Ɱ                     -   map (across c in E) with:
                   i                      -     first index (of c) in (p)
                      U2¦                 - reverse the second of the resulting list
                         o3               - replace 0s (not found) with 3s
                                            (offsetting a lack of eyebrows)
                           S              - sum (e.g. [[2,4],[5,1]] -> [7,5])
                            Ḣ             - head -> the sum of the relevant indices
                                                    zero if empty
                             ḟ0           - filter discard zeros
                               _7         - subtract 7
                                   ¡      - repeat...
                                  ®       - ...number of times: recall from register
                                 N        - ...action: negate
                                        $ - last two links as a monad:
                                     ”;   -   ';' character
                                       e  -   exists in (E)?
                                    +     - add
                                          - implicit print (the result is a list containing a single integer, which is printed as that integer)
O:6ṣ9Ẉ>/ȯḢƲ%5Ḣ - Link 1, should_reverse?: list of characters, E
O              - ordinals
 :6            - integer divide by six
   ṣ9          - split at nines (':' or ';')
          Ʋ    - last four links as a monad - f(x):
     Ẉ         -   length of each
       /       -   reduce by:
      >        -     greater than?
         Ḣ     -   head (x)
        ȯ      -   logical OR (replace a 0 with the list of ordinals of the left part)
           %5  - modulo by five - '(' and ')' give 1, others give 0
             Ḣ - head
```
]