[Question]
  [
Write a program or function that takes in a string of the characters `-=o.` where the `-=o`'s and `.`'s always alternate, character to character. The string will have an odd length greater than one and always start and end in one of `-=o`.
Basically, the input will look like a line of emoticon faces that share eyes in various states of sleepiness, e.g.
```
o.=.=.-.-.o.o
```
Your goal is to print or return the face that is either the sleepiest or the most awake (it's up to you which you choose). If there are multiple choices for who is sleepiest/most awake then any one of them may be output.
There are nine distinct faces and five levels of sleepiness:
```
-.- is 100% sleepy
-.= is 75% sleepy
-.o is 50% sleepy
=.- is 75% sleepy
=.= is 50% sleepy
=.o is 25% sleepy
o.- is 50% sleepy
o.= is 25% sleepy
o.o is 0% sleepy
```
In case it's not clear, the sleepiness percentage is computed by assigning `1` to `-` for fully asleep, `0.5` to `=` for half asleep, and `0` to `o` for awake. Then the sum of the two eye values divided by two is the percentage.
**The shortest code in bytes wins.**
# Test Cases
**Sleepiest**
```
-.- GIVES -.-
=.- GIVES =.-
o.o GIVES o.o
o.-.= GIVES -.=
=.-.= GIVES =.- OR -.=
o.-.= GIVES -.=
-.-.= GIVES -.-
o.o.- GIVES o.-
=.=.=.o GIVES =.=
-.=.=.= GIVES -.=
=.o.-.= GIVES -.=
o.-.o.=.= GIVES o.- OR -.o OR =.=
-.o.-.=.= GIVES -.=
o.o.o.o.o GIVES o.o
-.-.-.-.- GIVES -.-
o.=.=.-.-.o.o GIVES -.-
-.=.-.o.o.=.o.-.o.=.-.o.=.o.- GIVES -.= OR =.-
```
**Most Awake**
```
-.- GIVES -.-
=.- GIVES =.-
o.o GIVES o.o
o.-.= GIVES o.-
=.-.= GIVES =.- OR -.=
o.-.= GIVES o.-
-.-.= GIVES -.=
o.o.- GIVES o.o
=.=.=.o GIVES =.o
-.=.=.= GIVES =.=
=.o.-.= GIVES =.o
o.-.o.=.= GIVES o.=
-.o.-.=.= GIVES -.o OR o.- OR =.=
o.o.o.o.o GIVES o.o
-.-.-.-.- GIVES -.-
o.=.=.-.-.o.o GIVES o.o
-.=.-.o.o.=.o.-.o.=.-.o.=.o.- GIVES o.o
```
  
[Answer]
# Pyth, ~~12~~ 10 bytes
```
hoSN%2.:z3
```
This prints the sleepiest emoticon. Verify all test cases at once in the [Pyth Compiler](https://pyth.herokuapp.com/?code=hoSN%252.%3Az3&test_suite=1&test_suite_input=-.-%0A%3D.-%0Ao.o%0Ao.-.%3D%0A%3D.-.%3D%0Ao.-.%3D%0A-.-.%3D%0Ao.o.-%0A%3D.%3D.%3D.o%0A-.%3D.%3D.%3D%0A%3D.o.-.%3D%0Ao.-.o.%3D.%3D%0A-.o.-.%3D.%3D%0Ao.o.o.o.o%0A-.-.-.-.-%0Ao.%3D.%3D.-.-.o.o%0A-.%3D.-.o.o.%3D.o.-.o.%3D.-.o.%3D.o.-&debug=0).
*Credit goes to @Sp3000 for [the idea to use sorting](http://chat.stackexchange.com/transcript/message/25556328#25556328).*
### How it works
```
hoSN%2.:z3
              (implicit) Save the in z.
      .:z3    Compute all substrings of length 3.
    %2        Keep every seconds substring. This discards non-emoticons.
 o            Sort the emoticons by the following key:
  SN            Sort the characters of the emoticon.
                This works since '-' < '=' < 'o'.
h             Retrieve the first, minimal element.
```
[Answer]
# Python 2, ~~54~~ 53 bytes
```
f=lambda s:s and max((s+' ')[:3],f(s[2:]),key=sorted)
```
This is a function that returns the face that is most awake.
Many thanks to xnor for providing many tactical tricks to shorten my original algorithm.
[Answer]
# CJam, 12 bytes
```
q3ew2%{$}$0=
```
This prints the sleepiest emoticon. Try [this fiddle](http://cjam.aditsu.net/#code=q3ew2%25%7B%24%7D%240%3D&input=-.%3D.-.o.o.%3D.o.-.o.%3D.-.o.%3D.o.-) or [this test suite](http://cjam.aditsu.net/#code=qN%2F%7BS%2F(%3AQ%3B1%3E%0A%20%20Q3ew2%25%7B%24%7D%240%3D%0Ae%3D%7D%2F&input=-.-%20GIVES%20-.-%0A%3D.-%20GIVES%20%3D.-%0Ao.o%20GIVES%20o.o%0Ao.-.%3D%20GIVES%20-.%3D%0A%3D.-.%3D%20GIVES%20%3D.-%20OR%20-.%3D%0Ao.-.%3D%20GIVES%20-.%3D%0A-.-.%3D%20GIVES%20-.-%0Ao.o.-%20GIVES%20o.-%0A%3D.%3D.%3D.o%20GIVES%20%3D.%3D%0A-.%3D.%3D.%3D%20GIVES%20-.%3D%0A%3D.o.-.%3D%20GIVES%20-.%3D%0Ao.-.o.%3D.%3D%20GIVES%20o.-%20OR%20-.o%20OR%20%3D.%3D%0A-.o.-.%3D.%3D%20GIVES%20-.%3D%0Ao.o.o.o.o%20GIVES%20o.o%0A-.-.-.-.-%20GIVES%20-.-%0Ao.%3D.%3D.-.-.o.o%20GIVES%20-.-%0A-.%3D.-.o.o.%3D.o.-.o.%3D.-.o.%3D.o.-%20GIVES%20-.%3D%20OR%20%3D.-) in the CJam interpreter.
*Credit goes to @Sp3000 for [the idea to use sorting](http://chat.stackexchange.com/transcript/message/25556328#25556328).*
### How it works
```
q            e# Read all input from STDIN.
 3ew         e# Push all overlapping slices of length 3.
    2%       e# Keep every seconds slice. This discards non-emoticons.
      {$}$   e# Sort the slices by their sorted characters.
             e# This works since '-' < '=' < 'o'.
          0= e# Retrieve the first, minimal slice.
```
[Answer]
## Dyalog APL, ~~35~~ 28 bytes
```
{⊃{⍵[⍒{+/'.??o='⍳⍵}¨⍵]}3,/⍵}
```
This is a monadic function that takes the string on the right and outputs the sleepiest face.
```
    {⊃{⍵[⍒{+/'.??o='⍳⍵}¨⍵]}3,/⍵}'o.=.=.-.-.o.o'
-.-
```
[Answer]
# Prolog, ~~205~~ 189 bytes
**Code**  
```
r([X|T],[N|B],M):-N=M,write(X);r(T,B,M).
p(X):-findall(S,sub_atom(X,_,3,_,S),L),findall(E,(nth1(I,L,E),I mod 2=\=0),R),maplist(atom_codes,R,Q),maplist(sum_list,Q,S),min_list(S,M),r(R,S,M).
```
**Explanation**
```
r([X|T],[N|B],M):-N=M,write(X);r(T,B,M).
p(X):-findall(S,sub_atom(X,_,3,_,S),L),              % L = all sublists of length 3
      findall(E,(nth1(I,L,E),I mod 2=\=0),R),        % R = every other element of L
      maplist(atom_codes,R,Q),                       % Q = list of decimal ascii codes 
                                                           created from R
      
      maplist(sum_list,Q,S),                         % S = list of sums of R's lists
      min_list(S,M),                                 % M = minimum sum
      r(R,S,M).                                      % Prints first element in R with sum M
```
**Example**  
```
>p('-.=.-.o.o.=.o.-.o.=.-.o.=.o.-').
-.=
```
**Edit:** Saved 16 bytes by unifying r-clauses with OR.
[Answer]
**Clojure, 82 bytes**
```
(fn[x](println(apply str(apply min-key #(reduce +(map int %))(partition 3 2 x)))))
```
Bonus: the following smaller function prints the same face, but with more style!
```
(fn[x](println(apply min-key #(reduce +(map int %))(partition 3 2 x))))
```
[Test here.](http://www.tryclj.com/)
[Answer]
## Ruby, 59 bytes
Function returns sleepiest face, using the sorting trick.
```
f=->(s){s.split(?.).each_cons(2).min_by{|e|e.sort}.join(?.)}
```
Called like this:
```
f.call("o.=.=.-.-.o.o")
# => "-.-"
```
Works on awkward eye order due to internal sort of eyes:
```
f.call("=.-.o")
# => "=.-"
```
[Answer]
## [Minkolang 0.12](https://github.com/elendiastarman/Minkolang), 119 bytes
At first, I tried doing this short and really golfy. I gave up and went for something a bit more "fun", but still relatively golfy.
```
>2@fv$oI2:[9[i$z3[iciz1+q=]++3=tt"^"3zpt]$x$x]IX3140w
o.o1F
o.=1$
=.o1+
=.=12
o.-1:
-.o11
=.-1+
-.=13
-.-1[
/c0i<
\qO].
```
[Try it here!](http://play.starmaninnovations.com/minkolang/?code=%3E2%40fv%24oI2%3A%5B9%5Bi%24z3%5Biciz1%2Bq%3D%5D%2B%2B3%3Dtt%22%5E%223zpt%5D%24x%24x%5DIX3140w%0Ao%2Eo1F%0Ao.%3D1%24%0A%3D.o1%2B%0A%3D.%3D12%0Ao.-1%3A%0A-.o11%0A%3D.-1%2B%0A-.%3D13%0A-.-1%5B%0A%2Fc0i%3C%0A%5CqO%5D.&input=-%2E%3D.-.o.o.%3D.o.-.o.%3D.-.o.%3D.o.-)
### Explanation
But really, click on the link above and click `Slow`! Anyway...
```
>2@fv
```
This skips over the `fv`, which will be important later.
```
$o                                                  Read in whole input as characters 
  I2:                                               Half the stack length
     [                                              Open for loop (for each face)
      9[                                            Open another for loop - 9 repeats
        i$z                                         Stores loop counter in register
           3[                                       Open another for loop - 3 repeats
             ic                                     Copy char 1/2/3
               iz1+q                                Retrieve char from lookup table
                    =                               1 if equal, 0 otherwise
                     ]                              Close for loop
                      ++                            Add twice
                        3=                          1 if equal to 3, 0 otherwise
                          tt      t                 Ternary - executes first part when 0,
                                                    second part otherwise
                            "^"3zp                  Put a ^ next to the face that matched
                                   ]                Close lookup for loop
                                    $x$x            Dump first two characters
                                        ]           Close for loop
                                         IX         Dump the whole stack
                                           31       Push a 3, then a 1
                                             40w    Wormhole to (4,0) in the code
```
What all that did was put a `^` next to the faces that matched. So now the codebox might look like this:
```
>2@fv$oI2:[9[i$z3[iciz1+q=]++3=tt"^"3zpt]$x$x]IX3140w
o.o1F
o.=1$
=.o1+
=.=^2   <-- caret
o.-^:   <-- caret
-.o11
=.-1+
-.=^3   <-- caret
-.-1[
/c0i<
\qO].
```
Without the comments, of course. Now, the `40w` wormhole sent the instruction pointer to `v`, which immediately redirects it onto `F`. Now, `F` is a "gosub" command. It's like a goto, but you can return to where you called it. At the time `F` is encountered, the stack is `[3,1]`, so it jumps to the `1` (maybe) on the second row. As the program counter was heading downwards, it continues, pushing `1`s onto the stack along the way. That is...until it hits a `^`, at which point it's redirected back up, where it pushes each `1` again. The instruction pointer then hits `f`, which restores its position and direction (when `F` was encountered earlier). For convenience, I will take the following code and change its layout. (The `</\` serve to redirect the instruction pointer as needed.)
```
$+                 Sum up the whole stack
  2:               Divide by 2 (because each 1 was pushed twice)
    1+             Add 1 (shift down one row)
      3[           Open for loop - 3 repeats
        i          Push loop counter
         0c        Copy top of stack
           q       Retrieve face character
            O      Output as character
             ].    Close for loop and stop when it's done.
```
I'm actually kinda proud of how I used multiple features unique to Minkolang that I haven't often used before. Mainly the ternary and the gosub. Anyway, there you have it!
[Answer]
# C, 70 bytes
```
char*f(char*s){char*p=s[3]?f(s+2):s;return*s+s[2]>*p+p[2]?s[3]=0,s:p;}
```
The function returns the most awake face. It modifies the input string in place, so as to return a null-terminated string.
[Answer]
# Python 2/3, 54 ~~56~~ bytes
```
lambda x:".".join(max(zip(x[::2],x[2::2]),key=sorted))
```
Just wanted to take an alternative tack to xsot's recursive answer.
This takes the best (or worst?) tuple of adjacent pairs of eyes and joins them together.
Replace max with min to return the most sleepy (as is this returns the most awake)
Seems to work, using the following test:
```
for line in """-.- GIVES -.-
    =.- GIVES =.-
    o.o GIVES o.o
    o.-.= GIVES o.-
    =.-.= GIVES =.- OR -.=
    o.-.= GIVES o.-
    -.-.= GIVES -.=
    o.o.- GIVES o.o
    =.=.=.o GIVES =.o
    -.=.=.= GIVES =.=
    =.o.-.= GIVES =.o
    o.-.o.=.= GIVES o.=
    -.o.-.=.= GIVES -.o OR o.- OR =.=
    o.o.o.o.o GIVES o.o
    -.-.-.-.- GIVES -.-
    o.=.=.-.-.o.o GIVES o.o
    -.=.-.o.o.=.o.-.o.=.-.o.=.o.- GIVES o.o""".splitlines():
    inp, _, opts = line.partition(" GIVES ")
    optst = opts.split(" OR ")
    act = f(inp)
    print(inp, "expected", opts, "got", act, "equal?", act in optst)
```
Which gives the following result:
```
-.- expected -.- got -.- equal? True
=.- expected =.- got =.- equal? True
o.o expected o.o got o.o equal? True
o.-.= expected o.- got o.- equal? True
=.-.= expected =.- OR -.= got =.- equal? True
o.-.= expected o.- got o.- equal? True
-.-.= expected -.= got -.= equal? True
o.o.- expected o.o got o.o equal? True
=.=.=.o expected =.o got =.o equal? True
-.=.=.= expected =.= got =.= equal? True
=.o.-.= expected =.o got =.o equal? True
o.-.o.=.= expected o.= got o.= equal? True
-.o.-.=.= expected -.o OR o.- OR =.= got =.= equal? True
o.o.o.o.o expected o.o got o.o equal? True
-.-.-.-.- expected -.- got -.- equal? True
o.=.=.-.-.o.o expected o.o got o.o equal? True
-.=.-.o.o.=.o.-.o.=.-.o.=.o.- expected o.o got o.o equal? True
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 10 bytes
```
s₃ᶠġ₂hᵐoᵒh
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6k4O4Z5hqsoFRu/6htw6Ompoe7Omsfbp3wv/hRU/PDbQuOLASKZQAF8h9unZTx/3@0kq6erpKOgpIthMrXy4dQunq2UGEIAy6iixDJh2kFwXyIJJgDEc1H1psPE9eFiCPMAEOYyWAIkQGZpAvWCTcazNGDmJwP5YN5SrEA "Brachylog – Try It Online")
Translated from Dennis' Pyth answer.
[Answer]
# Mathematica, 61 bytes
```
"."
Sort[Partition[#~StringSplit~%,2,1]][[1]]~StringRiffle~%&
```
Goes for the sleepiest one.
[Answer]
# F# 60
```
fun s->Seq.max[for n in 0..2..String.length s-2->s.[n..n+2]]
```
Returns the most awake face (change `max` by `min` for the sleepest)
[Answer]
## Perl 5, 127 bytes
```
%h=qw[- 2 = 1];sub r{$b=0;$b+=$h{$_}for split'',pop;$b}($_)=<>;@a='o.o';while(/.../g){push@a,$& if(r$&)>r$a[-1];--pos}say$a[-1]
```
(I'm sure it's doable more briefly.) How it works:
1. Grab each three-character string from the string, with overlap by one (that's what the `--pos` does).
2. Append that three-character string to an array if its value exceeds that of the last element of the array; here, "value" is just the sum of its characters' values in sleepiness.
3. Print the last element of the array.
[Answer]
## ES6, ~~81~~ 72 bytes
```
a=>"-.-,-.=,=.-,-.o,=.=,o.-,=.o,o.=,o.o".split`,`.find(b=>a.includes(b))
```
Probably requires Chrome 45 or Firefox 41.
Thanks to @ETHproductions for saving 9 bytes.
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 55 bytes
[try it here!](http://fishlanguage.com/playground/ZMePES245vyjACmfR)
```
<v~i:i&0"."0
 >i:@+:&:@)?v&~i0(?v
 ^?)0i:r~r&~<;ooo$r<
```
Outputs most awake face.
Since the ASCII values for -, =, and o increase respectively, I could use that to my advantage. Basically it adds the values of the current and previous eye part, check if it's a higher value than before, if it is it saves the new value and updates what face that represents, then loops until the end of the input. Then outputs the face that remains. (I'm very pleased at how nicely all the code fits in place)
[Answer]
# [Perl 5](https://www.perl.org/) `-MList::Util=max -p`, 68 bytes
```
s|..(?=(.))|$t=max$t,ord($&)%15%4+ord($1)%15%4 .$&.$1|eg;$_=$t;s/.//
```
[Try it online!](https://tio.run/##K0gtyjH9/7@4Rk9Pw95WQ09Ts0alxDY3sUKlRCe/KEVDRU1T1dBU1UQbzDGEcBT0VNT0VAxrUtOtVeJtVUqsi/X19PX//7fV09XL/5dfUJKZn1f8X9fXVM/A0ABI@2QWl1hZhZZk5oBM/q9bAAA "Perl 5 – Try It Online")
Grabs each set of three characters, ignores the `.` in the middle, maps the addition of the other two to an integer in the range 0-4, concatenates that to the front of the emoticon face, then sorts by that. Grabs the last entry (most awake), removes the number from the front, and outputs it.
]