[Question]
  [
Write a program that accepts as input an emoticon and ouputs if the emoticon is happy or sad.
The program accepts a string as input or parameter, and should display the string "happy" if the input is in the happy emoticon list, or "sad" if the input is in the sad emoticon list.
You can assume the input is always a valid (happy or sad) emoticon, with no space or tabs around.
Here is a space separated list of happy emoticons:
```
:-) :) :D :o) :] :3 :c) :> =] 8) =) :} :^) :-D 8-D 8D x-D xD X-D XD =-D =D =-3 =3 B^D (-: (: (o: [: <: [= (8 (= {: (^:
```
Here is a space separated list of sad emoticons:
```
>:[ :-( :( :-c :c :-< :< :-[ :[ :{ 8( 8-( ]:< )-: ): >-: >: ]-: ]: }: )8 )-8
```
This is code-golf, so the shortest program wins.
  
[Answer]
# Python, 86 bytes
I should be sent to prison.
```
x=lambda c: ["happy","sad"][c[0]+c[-1:]in open(__file__).read(88)[::-1]]#<][><:>{:}(:)
```
The shortest I could come up with was equivalent to Martin's CJam answer, so I decided I'd hide all the sad emojis (minus the middle character if any) in the reverse of my code and use Python's `__file__` quine cheat.
Muahahaha.
[Answer]
# CJam, ~~33~~ 32 bytes
*Thanks to Dennis for saving 1 byte.*
```
q)"[(c<{"&\"])>}"&|"sad""happy"?
```
Looks like it's shorter to do the same thing without a regex...
[Test it here.](http://cjam.aditsu.net/#code=qS%2F%7B%3AQ%3B%0A%0AQ)%22%5B(c%3C%7B%22%26%5C%22%5D)%3E%7D%22%26%7C%22sad%22%22happy%22%3F%0A%0A%5DoNo%7D%2F&input=%3A-)%20%3A)%20%3AD%20%3Ao)%20%3A%5D%20%3A3%20%3Ac)%20%3A%3E%20%3D%5D%208)%20%3D)%20%3A%7D%20%3A%5E)%20%3A-D%208-D%208D%20x-D%20xD%20X-D%20XD%20%3D-D%20%3DD%20%3D-3%20%3D3%20B%5ED%20(-%3A%20(%3A%20(o%3A%20%5B%3A%20%3C%3A%20%5B%3D%20(8%20(%3D%20%7B%3A%20(%5E%3A%20%3E%3A%5B%20%3A-(%20%3A(%20%3A-c%20%3Ac%20%3A-%3C%20%3A%3C%20%3A-%5B%20%3A%5B%20%3A%7B%208(%208-(%20%5D%3A%3C%20)-%3A%20)%3A%20%3E-%3A%20%3E%3A%20%5D-%3A%20%5D%3A%20%7D%3A%20)8%20)-8)
## Explanation
This based on the same observation as the Retina answer, but this time matching happy faces doesn't have any benefit, so we'll match sad faces instead (because there's one less mouth to take into account). The solution is otherwise exactly the same, except that it's not implemented via regex substitution:
```
q)             e# Read input and split off last character.
"[(c<{"&       e# Set intersection with the sad right-hand mouths.
\              e# Pull up remaining emoticon.
"])>}"&        e# Set intersection with the sad left-hand mouths.
|              e# Set union, which amounts to a logical OR in this case.
"sad""happy"?  e# Pick the correct string.
```
[Answer]
# [Retina](https://github.com/mbuettner/retina), ~~38~~ 36 bytes
```
.+[])D3>}]|[<[({].+
happy
^...?$
sad
```
We can recognise all emoticons by their mouths, because none of the mouths is used as a hat or eyes in the other set (only in the same set). The happy ones have one more mouth to take into account, but they have the benefit that the mouths don't appear in the other set at all, not even as noses (the opposite is not true: `c` is both a sad mouth and a happy nose). This means we can avoid using anchors but instead just ensure that there are more characters on the other side of the mouth.
So the valid mouths for happy faces are `] ) D 3 > }` on the right or `< [ ( {` on the left. We match those with `.+[])D3>}]|[<[({].+` and replace them with `happy`. If we didn't match there will be two or three characters in the string (the emoticon), but if we did there will be five (`happy`). So in a second step we replace two or three characters with `sad`.
[Answer]
# JavaScript (ES6), 46
Using a regexp to find sad emoticons, that are those beginning with `>)]}` or ending with `<([{c`. Side note: other regexps here may be shorter but I'm not sure to understand them.
Usual note: test running the snippet on any EcmaScript 6 compliant browser (notably ~~not~~ newest Chrome but not MSIE. I tested on Firefox, Safari 9 could go) 
**Big news** It seems arrow functions finally arrived to Chrome land! [Rel 45, august 2015](https://www.chromestatus.com/feature/5047308127305728)
```
F=s=>/^[\])}>]|[[({<c]$/.test(s)?'sad':'happy'
//Same length
X=s=>/[\])}>].|.[[({<c]/.test(s)?'sad':'happy'
Y=s=>s.match`].|[)}>].|.[[({<c]`?'sad':'happy'
                 
//TEST
out=x=>O.innerHTML+=x+'\n';
sad='>:[ :-( :( :-c :c :-< :< :-[ :[ :{ 8( 8-( ]:< )-: ): >-: >: ]-: ]: }: )8 )-8'.split` `
happy=':-) :) :D :o) :] :3 :c) :> =] 8) =) :} :^) :-D 8-D 8D x-D xD X-D XD =-D =D =-3 =3 B^D (-: (: (o: [: <: [= (8 (= {: (^:'.split` ` 
out('The sad faces')                   
sad.forEach(x=>out(x + ' is ' + F(x)))
out('\nThe happy faces')
happy.forEach(x=>out(x + ' is ' + F(x)))
```
```
<pre id=O></pre>
```
[Answer]
# Julia, 87 69 bytes - saved 18 bytes thanks to Alex A.
```
s=readline();print(s[end-1] in")D]3>}"||s[1] in"([<{"?"happy":"sad")
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~77~~ ~~75~~ ~~74~~ ~~72~~ ~~61~~ 55 bytes
```
lambda e:('happy','sad')[e[-1]in'[(c<{'or e[0]in'])>}']
```
[Try it online!](https://tio.run/##HY/NisMwDITvfYq5BMtQL7vkEkSdw@KHKGQdyOaHBrpJqHtoKXn27KQw8idrkISW5/0yT/k2@J/t2vz9dg16FXNpluVpjiY1nbFVX7mvOE6mkvb0MvMNffW5/6MtVxO3oWn7BA@jzkKpAJ2JCM2hLbMSPqKw8MxXaE24gGKPgAfxCDgT5wBP@B05fI7vOkCcQqhZUSlOfD2kgHi8WK0VpVacJ1DKtdxInKCUo0G9UAi3CSKLluMsm9zeiEhExcpaQaswH2m5jncxMPZwGHhrwjhB3jdaPWC5jRPt7IYsAQYZJB0xSLL2iH7q/Ltz@wc "Python 3 – Try It Online")
## How does it work
If a face string starts with `])>}` or ends with `[(c<{`, it is sad, otherwise it is happy. Tuple indexing is used as `if`.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 50 bytes
```
(rh{,"[(c<{":Im?};?h{,"])>}":Im?}),"sad".;"happy".
```
### Explanation
```
(                              ),"sad".;"happy".  § If what's in the parentheses is true,
                                                  § output "sad", else output "happy".
 rhA                                              § Unify A with the last char of the input
    ,"[(c<{":ImA                                  § True if A is a char of "[(c<{"
                ;                                 § OR
                 ?hA                              § Unify A with the first char of the input
                    ,"])>}":ImA                   § True if A is a char of "])>}"
```
[Answer]
# Python, 159 bytes.
```
i,e=raw_input(),0
for c in i:e=(e,i.index(c))[c in":=8xXB"]
f,s,h=i[:e],i[e+1:],0
for c in f:h+=c in"[(c<{"
for c in s:h+=c in")]}>D"
print["Sad","Happy"][h>0]
```
[Answer]
# MATLAB, ~~85~~ 83 bytes
There must be a way to reduce the size here.
```
e=input('');if any([e(end)=='[(c<{',e(1)=='])>}']),'sad';else 'happy';end,disp(ans)
```
Input is a smiley string. First and last characters will be compared to determine whether it's sad. If not, it's happy.
I was able to save 2 bytes by not displaying either, but assigning them to MATLAB's default variable (ans) instead and then displaying ans after the if-statement. But I'm convinced it can be improved somehow.
2 bytes improvement by changing *function s(e),* to *e=input('');*.
[Answer]
# PowerShell, 92 Bytes
```
param([char[]]$a)if("<[({".IndexOf($a[0])+"})D3]>".IndexOf($a[-1])-eq-2){"sad"}else{"happy"}
```
A little wordy, but as a bonus, it doesn't use regex!
This takes advantage of the .NET `<string>.IndexOf()` function that returns `-1` if the character *isn't* found in the string. So, if the first character isn't a "happy" character, the first `IndexOf()` will be -1 -- likewise for the last character. So, if it's a sad face, the `IndexOf()`s will always sum to -2, meaning the `-eq-2` is `$TRUE`, and thus `sad` gets printed.
---
### Bonus variant: PowerShell with Regex, 95 bytes
```
param([char[]]$a)if(($a[0]-match"[<\[\(\{]")-or($a[-1]-match"[\}\)D3\]>]")){"happy"}else{"sad"}
```
[Answer]
# [Python 3](https://docs.python.org/3/), 75 bytes
```
lambda y:"sad"if re.match("(.*[[(c<{]$)|(^[\])>}])",y)else"happy"
import re
```
[Try it online](https://tio.run/##HY/NioNAEITvPkUhC/aEmIsXaTIeFh8iYEZwjRLBPxwPETfP7lYWauZrqqluet7W5zQmR2vvR18NP48Km4a@eoRdi6W5DNVaPyWUy6kopL7u7sv8SlncncnezoTnzTS9b8JnNc9bGHTDPC0rc0db1Y2HRaSxgVI5dCIcNIHWrDJYh9TAsn5DSyLOkX5ejhfxynEjbjksYT9IYBN8lzkkVgg1KQrFlb@FpBCLnW6pyLTgPIFScc2NxBVKxWxQO1LhNoGjaTjOMBR/gnCEU7zppWyl0cXPfbdKhMgEQTst8OhG/J@oAealG1fxZ7TijQmOPw "Python 3 – Try It Online")
The regex import makes it a bit too long, as well as the inability to use `None` as an array index. But I like regex :)
[Answer]
# Java 8, 52 bytes
```
e->e.matches(".+[\\[(c<{]|[)>\\]}].+")?"sad":"happy"
```
[Try it online.](https://tio.run/##jVE9T8MwEN35FU@ebFXJ0iW6NkFCWenCgpS4knEDTWmTqDGIquS3l9c2CAYGpHd@92Gd35037t1Fm9XryW9d3@Pe1c3xBqibUO2fna@wOIfAQ9jXzQu8Hp3KzJgfaEQfXKg9FmiQ4lRFWRXvXPDrqtcqnhRlWWg/P9rPwmRlaQcbT5S5Vb1bKVFr13UHdZpdO3VvT1t2Ghu@t/UKO0oaXy0snLnqeW7331IuHSBQEhkIkUNakoVMIZ5ehtQiMUjpD5AlKcqRnC3HB@kjxyPpMUdKSs80RTrF3TKHjgSaaAWFYM4zhU6gUxyZXYqK@25bB62gjLlo47YOfah2cfsW4o4aw7bRF5UTVQY1aWJ/Dc1liX9eHyu/xuS6zkNmUlC9hhCR53ykOYSIWCCOSDRn07BMGoo3goyUCSzJCgbmEpaSf0rnyz/CGZjx74fTFw)
**Explanation:**
```
e->          // Method with String as both parameter return-type
  e.matches( ".+[\\[(c<{]|[)>\\]}].+")                   
             //  Checks if the input matches the regex
   ?"sad"    //  If it does: output "sad"
   :"happy"  //  Else: output "happy"
```
Java's [`String#matches`](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#matches(java.lang.String)) implicitly adds `^...$` to match the entire String, which is why it is shorter to check for sad faces instead of checking for happy faces like most other answers do with `.+[\\])D3>}]|[<\\[({].+` (because my regex would fail in [*@MartinEnder*'s Retina answer](https://codegolf.stackexchange.com/a/57755/52210) for example, due to the happy test case `:c)`).
**Regex explanation:**
```
^.+[\\[(c<{]|[)>\\]}].+$
^                           Start of the string
 .+                          One or more characters,
   [\\[(c<{]                 followed by one of "[(c<{"
            |               Or
             [)>\\]}]        One of ")>]}",
                     .+      followed by one or more characters
                       $    End of the string
```
[Answer]
# [AutoHotkey], 78 bytes
```
InputBox,e
MsgBox % RegExMatch(e,"(^[\])>}].+$)|(^.+[\[(c<{]$)")?"sad":"happy"
```
## How does it work
Using RegEx and ternary operator. Nothing new, as some answers used this method too.
If input string starts with `])>}` or ends with `[(c<{`, it is sad, otherwise it is happy.
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 33 bytes
```
$_=/.[[(c<{]$|[\])>}]./?sad:happy
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lZfLzpaI9mmOlalJjomVtOuNlZP3744McUqI7GgoPL/f6tkzX/5BSWZ@XnF/3V9TfUMDA3@6xYAAA "Perl 5 – Try It Online")
]