text:
Tell me how many math problems I have to do!
My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me.
Specifications

You will get a string detailing the problems that I have to complete as args, stdio, etc.
They will be comma separated (possibly comma-space separated)
It will include single problems in the form of just a number (e.g. 79)
And ranges in the form 17-18 (again, you have to deal with optional spaces)
The ranges are inclusive of both ends
The ranges will optionally be suffixed by odd or even, which you have to take into account.
A set of ranges/pages will be prepended by a page number in the form pg. 545: , again having to deal with optional spaces. You can safely ignore these, as you need to get the problems over all the pages
The text may be in uppercase or lowercase, but will not be both.
Return, stdout, etc. the number of problems I have to do for homework.
Since this is code-golf, shortest code in bytes wins!

Test Cases
pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even   ->    27
pg. 34: 1                                                    ->    1
PG. 565: 2-5,PG.345:7                                        ->    5
pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80                ->    70
pg.492: 2-4 odd,7-9 even                                     ->    2

Can the professor give you a range of 2-4 odd? It appears to cause some problems for simpler approaches.

^ I think this should be a test case, according to the current problem statement.

There should be this test case: pg.492: 2-4 odd,7-9 even   ->   2

Can the ranges overlap? E.g. 22-26,25-30?

@RetoKoradi no.

@BjörnLindqvist yes

Also, is there always a space before odd and even?

@mbomb007 yeah.

CJam, 61 58 51 48 46 43 41 38 bytes
leuS-',/{':/W>:~_2*2<~z),>1f&\,5--~}%,

Verify the test cases in the CJam interpreter.
How it works
leuS-      e# Read a line from STDIN, convert to uppercase and remove spaces.
',/        e# Split at commas.
{          e# For each chunk:
  ':/W>    e#   Split at colons and only keep the last chunk.
  :~       e#   Evaluate the string inside the array.
  _2*      e#   Copy the array, repeated twice.
  2<       e#   Keep only the first two elements.

           e#   In all possible cases, the array now contains exactly two
           e#   integers, which are equal in case of a single problem.

  ~        e#   Dump the array on the stack.
  z),      e#   Push [0 ... -N], where N is the second integer.
  >        e#   Discard the first M elements, where M is the first integer.
  1f&      e#   Replace each element by its parity.
  \,       e#   Push L, the length of the original array.

           e#   EVEN and ODD all push elements, so L is 1 for single problems,
           e#   2 for simple ranges, 5 for odd ranges and 6 for even ranges.

  5--      e#   Discard all elements equal to L - 5 from the array of parities.

           e#   This removes 0's for odd ranges, 1's for even ranges, -3's for
           e#   other ranges and -4's for single problems, thus counting only
           e#   problems of the desired parities.

  ~        e#   Dump the resulting array on the stack.
}%         e# Collect the results in an array.
,          e# Compute its length.

Does this work with the newest test case?

It does. I've added the latest test case to the link.

Perl - 47 Bytes
#!perl -p054
{map$\+=($_%2x9^lc$')!~T,$&..$'*/\d+ ?-/}}{

Amended to pass the new test case.

Original
Perl - 36 Bytes
#!perl -p054
$\+=/\d+ ?-/*($'-$&>>/o|e/i)+1}{

Counting the shebang as 4, input is taken from stdin.

Sample Usage
$ echo pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even | perl math-problems.pl
27

$ echo pg. 34: 1 | perl math-problems.pl
1

$ echo PG. 565: 2-5,PG.345:7 | perl math-problems.pl
5

$ echo pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80 | perl math-problems.pl
70

Caveats
For even/odd ranges, it is expected that at least one of the endpoints matches the parity of the range. For example, 11-19 odd, 11-20 odd, and 10-19 odd will all be correctly counted as 5, but 10-20 odd will be over-counted as 6.

how does this work for pg. 20: 13-15 even? or pg. 20: 13-14 even?

@NotthatCharles added a caveat.

* is one character shorter than &&, making for an easy improvement: $\+=/\d+ ?-/*($'-$&>>/o|e/i)+1for@F}{

In case anybody else is having trouble: This seems to require a specific version of Perl. It works fine with 5.20, but prints nothing with 5.18.

@Dennis I was surprised myself when reading perlrun that "-F implicitly sets both -a and -n." I think it's best to add -a in this case, if it only works for 5.20 onwards.

Note that the caveat must be fixed now, according to the newest test case.

Man, this is clever! Unless I'm missing something, you should be able to eliminate lc=~.

@Dennis TT^01 → de, which would fail to work correctly if a range were suffixed with EVEN or ODD.

I got that the T^ part, but somehow missed that lc changed the case of $'. Prepending lc to $' would have been slightly shorter. That should still work for either approach: lc$'!~(T^lc$_%2) or ($_%2x9^lc$')!~T

@Dennis for the previous version, it would have required parentheses. !~T is genius though, thanks!

Python 2, 259 253 249 239 bytes
Try it here
This can probably still be golfed more.
Edit: Fixed a bug that caused mine to not work for 2-4 even as I had expected. Then made an adjustment for that fix. That fix saved me four bytes!
Edit: Now uses input() and +2 bytes for the two quotation marks the user must surround input with.
import re
c=0
for x in re.sub(r'..\..*?:','',input()).replace(' ','').split(','):
 y=x.split('-')
 if len(y)<2:c+=1
 else:
    a,b=y[0],y[1];d=int(re.sub('[A-z]','',b))-int(a)+1
    if b[-1]>':':d=d/2+d%2*(int(a)%2==ord(b[-3])%2)
    c+=d
print c

Less golfed (with comments! :D):
I hope these comments help some. I'm still not quite sure if I explained that last complex line correctly or not.
import re
def f(s):
    c=0
    l=re.sub(r'..\..*?:','',s).replace(' ','').split(',')   # remove pg #'s and split
    for x in l:
        y=x.split('-')
        if len(y)<2:                                # if not a range of numbers
            c+=1
        else:
            a,b=y[0],y[1]                           # first and second numbers in range
            d=int(re.sub('[A-z]','',b))-int(a)+1    # number of pages
            if b[-1]>':':                           # if last character is not a digit
                # half the range
                # plus 1 if odd # of pages, but only if first and last numbers in the range
                #       are the same parity
                # ord(b[-3])%2 is 0 for even (v), 1 for odd (o)
                d=d/2+(d%2)*(int(a)%2==ord(b[-3])%2)
            c+=d
    print c

Just a little thing, since you are using Python 2, you can use spaces and tabs (1 byte each) as different indents. Relevant tip

Also found I had the count wrong at first. Copying tabs from the editors converts them to spaces.

You can save at least 4 bytes by doing s=raw_input() and removing some indentation.

Pyth, 43 42 44 42 bytes
lsm-%R2}hKvMc-ecd\:G\-eK?}\ed}edGYc-rzZd\,

Try it online: Demonstration or Test harness
I think I can still chop one or two bytes.
Explanation
lsm-%R2}hKvMc-ecd\:G\-eK?}\ed}edGYc-rzZd\,  implicit: z = input string
                                    rzZ     convert z to lower-case
                                   -   d    remove all spaces from z
                                  c     \,  and split by ","
  m                                         map each part d to:
               cd\:                           split d by ":"
              e                               and only use the last part (removes page number)
             -     G                          remove all letters (removes odd/even)
            c       \-                        split by "-"
          vM                                  and evaluate all (one or two) numbers
         K                                    and store the result in K
       }hK            eK                      create the list [K[0], K[0]+1, ..., K[-1]]
    %R2                                       apply modulo 2 to each element
   -                                          and remove:
                         }\ed                   "e" in d (1 for in, 0 for not in)
                        ?    }edG               if d[-1] in "abcde...z" else
                                 Y              dummy value
 s                                            combine all the lists
l                                             print the length

Does this work with the newest test case?

@mbomb007: It does.

Factor - 488 bytes:
USING: arrays ascii kernel math math.parser math.ranges pcre sequences ;
IN: examples.golf.homework

: c ( a -- b )
    >lower "(?:[,:]|^) *(\\d+) *(?:- *(\\d+) *(e|o)?)?" findall [
        rest [ second dup string>number swap or ] map
        dup length 1 = [ drop 1 ] [
            dup length 2 = [ first2 swap - 1 + ] [
                first3 "o" = [ [a,b] [ odd? ] count ] [
                    [a,b] [ even? ] count
                ] if
            ] if
        ] if
    ] map sum ;

JavaScript (Spidermonkey console) - 139
It's just easier to test on the command line.
for(r=/[:,] *(\d+)[- ]*(\d+)? *(o|e)?/gi,m=readline(z=0);f=r.exec(m);z+=!b||((p=b-a)%2||!c|a%2^/e/i.test(c))+p/(2-!c)|0)[,a,b,c]=f
print(z)

Ungolfed:
// any number set after "pg:" or a comma
// \1 is FROM, \2 is TO, \3 is odd/even
r=/[:,] *(\d+)[- ]*(\d+)? *(o|e)?/gi;
m=readline();
z=0; // this is the sum.
while(f=r.exec(m)){
    [,from,to,oddEven]=f;
    if(!to) {
        z++;
    } else {
        if((to-from)%2) {
            // if to and from are not the same parity, add 1
            z++;
        } else {
            // if to and from are not the same parity...
            if(!oddEven) {
                // and we don't have a parity marker, add one
                z++;
            } else if(a%2 != /e/i.test(c)) {
                // if we do have a parity marker,
                // AND the parity of from and to matches the
                // parity of the oddEven sign, then add 1
                z++;
            }
        }
        // then add the difference between to-from and
        // if oddEven exists, divide by two and round down
        z+=(to-from)/(oddEven?2:1)|0;
    }

}
print(z);

Can [,from,to] just simply be [from,to]?

@TuukkaX no because that is to discard the first value of the array from r.exec, which contains the entire matched string.

Bash 344 315 306 294 262 252 242 240
IFS=,
o(){ R=0;for ((i=$1;i<=$2;R+=i++%2));do :
done
}
e(){ q=$R;o $*;((R=q-R))
}
for c in ${1,,};do
c=${c#*:}
m=${c##* }
l=${c%-*}
l=${l// }
h=${c#*-}
[[ a< $m ]]&&h=${h% *}
h=${h// }
((R=h-l+1))
eval "${m::1} $l $h"
((t+=R))
done;echo $t

I don't think I've golfed this as much as is possible but not bad for a first submission.
Commented version below.
IFS=, # Setup IFS for the for loops, We want to be able to split on commas

o(){ # Odd
    R=0  # Reset the R variable

    # Increments R for each odd element in the range
    # $1-$2 inclusive
    for ((i=$1;i<=$2;R+=i++%2));do
        : # Noop command
    done
}

e(){ # Even
    # Save R, it contains the total number of elements between low
    # and high
    q=$R
    # Call Odd, This will set R
    o $*
    # Set R = total number of elements in sequence - number of odd elements.
    ((R=q-R))
}

# This lowercases the firs arg. IFS causes it to split on commas.
for c in ${1,,};do
    c=${c#*:}  # Strips the page prefix if it exists
    m=${c##* }  # Capture the odd/even suffix if it exists
    l=${c%-*}  # Capture low end of a range, Strips hyphen and anything after it
    l=${l// }  # Strips spaces
    h=${c#*-}  # Capture high end of a range, Strips up to and including hyphen

    # If we have captured odd/even in m this will trigger and strip
    # it from the high range variable.
    [[ a< $m ]]&&h=${h% *}
    h=${h// }  # Strip Spaces

    # Give R a value.
    # If we are in a range it will be the number of elements in that range.
    # If we arent l and h will be equal are R will be 1
    ((R=h-l+1))

    # Call the odd or even functions if we captured one of them in m.
    # If we didnt m will contain a number and this will cause a warning
    # to stderr but it still works.
    eval "${m::1} $l $h"

    # Add R to total
    ((t+=R))
done

# Print result
echo $t

Run the test cases:
bash math.sh "pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even"
bash math.sh "pg. 34: 1"
bash math.sh "PG. 565: 2-5,PG.345:7"
bash math.sh "pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80"
bash math.sh "pg.492: 2-4 odd,7-9 even"

Depending on how I read the rules it could be possible to save another 4 bytes. If even/odd is always lowercase ${1,,} can be changed to $1

Does this work with the newest test case?

Just tested it and yes it does.

JavaScript (ES6), 149
Run snippet in Firefox to test

F=s=>s.replace(/([-,.:]) *(\d+) *(o?)(e?)/ig,(_,c,v,o,e)=>
  c=='-'?(t+=1+(o?(v-(r|1))>>1:e?(v-(-~r&~1))>>1:v-r),r=0)
  :c!='.'&&(t+=!!r,r=v)
,r=t=0)&&t+!!r

// Less golfed

U=s=>{
  var r = 0, // value, maybe range start
  t = 0; // total
  s.replace(/([-,.:]) *(\d+) *(o?)(e?)/ig, // execute function for each match
    (_ // full match, not used
     , c // separator char, match -:,.
     , v // numeric value
     , o // match first letter of ODD if present
     , e // match first letter of EVEN if present
    )=>
    {
      if (c == '-') // range end
      {
        t++; // in general, count range values as end - start + 1
        if (o) // found 'odd'
        {
          r = r | 1; // if range start is even, increment to next odd
          t += (v-r)>>1; // end - start / 2
        }
        else if (e) // found 'even'
        {
          r = (r+1) & ~1; // if range start is odd, increment to next even
          t += (v-r)>>1; // end - start / 2
        }
        else
        {
          t += v-r; // end - start
        }
        r = 0; // range start value was used
      }
      else if (c != '.') // ignore page numbers starting with '.'
      {
        // if a range start was already saved, then it was a single value, count it
        if (r != 0) ++t;
        r = v; // save value as it counld be a range start
      }
    }
  )
  if (r != 0) ++t; // unused, pending range start, was a single value
  return t
}

// TEST

out=x=>O.innerHTML+=x+'\n';

test=["pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even",
"pg. 34: 1", "PG. 565: 2-5,PG.345:7",
"pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80"];

test.forEach(t=>out(t + ' --> ' + F(t)))

C++ 226 224 222
I know I'm kinda late for the party, but this seemed like a fun problem and lack of entries using C-family languages bothered me.
So here's a C++ function using no regexp or string substitution, just some simple math:
void f(){char c;int o=0,i,j;while(cin>>c)c=='p'||c==80?cin.ignore(9,58):cin.unget(),cin>>i>>c&&c==45?cin>>j>>c&&(c=='e'||c=='o')?cin.ignore(9,44),c=='e'?i+=i&1,j+=!(j&1):(i+=!(i&1),j+=j&1),o+=(j-i)/2:o+=j-i:0,++o;cout<<o;}

Ungolfed:
void f()
{
  char c;
  int o=0,i,j;
  while(cin>>c)
    c=='p'||c==80?cin.ignore(9,58):cin.unget(),
    cin>>i>>c&&c==45?
      cin>>j>>c&&(c=='e'||c=='o')?
        cin.ignore(9,44),
        c=='e'?
          i+=i&1,j+=!(j&1)
        :(i+=!(i&1),j+=j&1),
        o+=(j-i)/2
      :o+=j-i
    :0,
    ++o;
  cout<<o;
}

I didn't say it would be readable, now did I? :) Ternary operators are hell. I tried my best to (sort of) format it, though, so I hope it helps at least a little bit.
Usage:
#include <iostream>
using namespace std;

void f(){char c;int o=0,i,j;while(cin>>c)c=='p'||c==80?cin.ignore(9,58):cin.unget(),cin>>i>>c&&c==45?cin>>j>>c&&(c=='e'||c=='o')?cin.ignore(9,44),c=='e'?i+=i&1,j+=!(j&1):(i+=!(i&1),j+=j&1),o+=(j-i)/2:o+=j-i:0,++o;cout<<o;}

int main()
{
  f();
}

207 bytes

Python 2 - 163 bytes:
Try it here
Input must be given inside quotes

import re
print len(eval(re.sub('([^,]+:|) *(\d+) *-? *(\d*)(?=.(.)).*?,',r'[x for x in range(\2,\3+1 if \3.0 else \2+1)if x%2!="oe".find("\4")]+',input()+',[]')))

Explanation:
The general approach is to convert the existing input into valid python, then evaluate this. Each comma separated value is converted to an array, which are then all appended together and the length gives the final result.
For example, with the input 12-15 odd,19, before evaluation the regex substitution will produce:
[x for x in range(12,15+1 if 15.0 else 12+1)if x%2!="oe".find("o")]
+[x for x in range(19,+1 if .0 else 19+1)if x%2!="oe".find("[")]
+[]

To break this down further:

15+1 if 15.0 else 12+1 This bit will make sure the second argument
of range() is correct depending if there is a range or a single value
given (if \3 is empty, \3.0 will evaluate to false).
if x%2!="oe".find("o") Depending on the value found two characters away
from the final digit in the range ((?=.(.)) in the regex - lookahead two characters without consuming them), there
are three possible outcomes:

x%2!="oe".find("o") evaluates to x % 2 != 0 (only odd matched)
x%2!="oe".find("e") evaluates to x % 2 != 1 (only even matched)
x%2!="oe".find("[") evaluates to x % 2 != -1 (this character could be multiple things as it's just two characters away from the
last digit, but will only be o or e if odd/even is intended)

The seemingly random +[] on the end is to ensure that the last token in the comma-separated list has a character two away from the last digit, but also allows us to append something to the end to use up the last '+' which would have been trailing otherwise.

Go, 358 bytes
import(."fmt";."regexp";."strings")
func f(s string)(O int){C:=Contains
for _,m:=range MustCompile(`pg\.\d+:`).Split(ReplaceAll(ToLower(s)," ",""),-1){for _,r:=range Split(m,",") {if r==""{continue}
l,h,e,o:=0,0,C(r,"even"),C(r,"odd")
Sscanf(r,`%d-%d`,&l,&h)
h=max(h,l)
h++
for i:=l;i<h;i++{if e&&i%2<1{O++}else if o&&i%2>0{O++}else if !e&&!o{O++}}}}
return}

Attempt This Online!
Does some input preprocessing (to lowercase, remove spaces), then splits on the pages. After that, for each problem range (matches split on commas), add to the problem count. If it's even only count on even indexes, and the same for odds. If neither, count on each index.


text:
Chute-A-Pearing
Here are five images of pears and a steel chute:

A: B: C: D: E:
These are only thumbnails, click them for full size!

(I made these with Algodoo.)
This class of images always has the following properties:

They are always 400×400 pixels with a white background. (It may not be exactly white since SE images are lossily compressed.)
They have 1 to 4 identical pears, each rotated and positioned in (almost) any way.
They have one vertical steel chute that reaches to the bottom of the image.
Other than the bottom of the chute, the chute and the pear bounding boxes (bounding box example) never touch or go out of the image bounds.
The bounding boxes of the pears never overlap each other nor overlap the chute.
The pears may be under the sloped part of the chute, as in B, C, and D. (So the bounding box of the chute may overlap the bounding box of a pear.)
The chute may have any horizontal and vertical position as long as there is enough room for all the bounding boxes of the pears to fit freely above it (no "barely fits" cases will be tested) and part of the column portion is visible.

Challenge
Write a program that takes in such an image and outputs another 400×400 image with the chute in the same place, but with the pears repositioned so they are all above the chute (so they can fall into it and be juiced and whatnot).
The requirements for the output image are:

All the pears in the input image must be repositioned such that they are above the chute, between the left and right edge of its funnel. (Above an edge is not ok.)
Each pear must maintain its rotation angle. (So you should be cutting and pasting the pears, not redrawing them.)
The pears must not overlap or touch each other or the chute. (The pear bounding boxes may overlap though.)
The pears must not touch or go out of the image bounds.

Here are examples of valid outputs for the five sample images:

A: B: C: D: E:
These are only thumbnails, click them for full size!

Note that the input image for E was already a valid output, but rearranging the pears when not technically necessary is just fine.
Details

Take the filename of the image or the raw image data via stdin/command line/function call.
Output the image to a file with the name of your choice or output the raw image file data to stdout or simply display the image.
Any common lossless image file format may be used.
Graphics and image libraries may be used.
A few incorrect pixels here and there (due to lossiness or something) is not a big deal. If I can't tell anything is wrong visually then it's probably alright.

The shortest code in bytes wins. Tiebreaker is highest voted post.

Since I have a Khan Academy account, and this seems perfect to solve there, can I solve it on Khan Academy? There is only one complication: external images are not allowed. Luckily I can run the images through this to convert them to Khan Academy–friendly data. Is this acceptable?

@BobTheAwesome So you want to post a JavaScript answer? That's fine, though it's supposed to input and output 400x400 images. You can post your work to show off how you did it with KA but I may not accept it as winner if it doesn't work on 400x400 images.

A perfect coincidence; Khan Academy just so happens to have a default of a 400x400px canvas for Javascript+Pjs.

No!! Imagenator is super slow on 400x400 images!!

Python 2.7, 636 bytes
import sys;from PIL.Image import*
_,m,R,I,p,H=255,400,range,open(sys.argv[1]).convert('RGB'),[],0
w,h=I.size;W,A,P,L=(_,_,_),[(x,y)for x in R(w)for y in R(h)],I.load(),I.copy()
try:
 while 1:
    s,x,y,X,Y=[[a for a in A if P[a][0]<50][0]],m,m,0,0
    while s:c=(a,b)=s.pop();x,y,X,Y=min(x,a),min(y,b),max(X,a),max(Y,b);P[c]=W;s+=[n for n in[(a+1,b),(a,b+1),(a-1,b),(a,b-1)]if n in A and P[n]!=W]
    p+=[((x,y,X,Y),X-x,Y-y)]
except:0
def G(a):r,g,b=P[a];return r==g==b and r<_
g=[a for a in A if G(a)]
(z,t),W=g[0],max([x for x,y in g]);t-=1
for r,w,h in p:
 if z+w>W:z,_=g[0];t-=H;H=0
 I.paste(L.crop(r),(z,t-h,z+w,t));z+=w;H=max(h,H)
I.show()

EDIT : now removes the alpha channel before handling the image, and aligns the pears on several rows if necessary
Produced images :

and with vertical pears (takes around 3 minutes on my computer):

Are the images befores/afters? If so I think you've taken the wrong ones for B-E...

input image on the left, and output images on the right... they're not pixel-perfect at all due to rescaling and copy-pasting, I've put them just to give hints on how the script works..

Will this work if all the pears are horizontal?

actually no... for two reasons :it falls in into an infinite loop because this particular image has an alpha channel ->fixing the script so it converts the image first. The other reason it that I removed the code that aligns the pears on several rows -> putting it back

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
What's the time?
I like to save time quite literally, by wearing three watches on my wrist... Problem is they each give a different time. One watch is x minutes behind the actual time. One watch is x minutes ahead of the actual time. The last watch shows the actual time.
Problem is, I can't tell which watch has the correct time...
From the time displayed on each watch, determine the actual time. If it is not possible to determine the time, print "Look at the sun".
Input:
Three readings, separated by single space characters: H1:M1 H2:M2 H3:M3
In each reading H1,H2,H3 represent the hours displayed (0 < H1,H2,H3 < 13), and
M1,M2,M3 represent the minutes displayed (0 <= M1,M2,M3 < 60). If the number of
minutes is less than 10, a leading 0 is prepended in the input. Similarly, is the number of hours is less than 10, a leading 0 is prepended in the input.
Output: The correct time is HH:MM where HH:MM is the correct time. If no correct time can be determined, it displays Look at the sun.
Input 1: 05:00 12:00 10:00
Output 1: The correct time is 05:00
Input 2: 11:59 12:30 01:01
Output 2: The correct time is 12:30
Input 3: 12:00 04:00 08:00
Output 3: Look at the sun
Shortest code wins... No special penalties apply. Also, bear in mind that we're dealing with a 12-hour clock... I don't care about AM or PM... Imagine we're dealing with analogue watches...

By correct time, you mean the current local time ?

@Optimizer One of the watches will contain the correct time, the other two will be X minutes plus/minus from the correct time... I've mentioned that in the brief...

@Dennis Output 3 clearly shows a response of Look at the sun, so yes...

Why is Output 3 look at the sun? Would 8:00 not be correct, and why not?

@sanchises Because they're 4 hours apart. 12:00 is exactly between 8:00 and 4:00 too, you know...

@Siguza I knew I was missing something obvious!

You say the output is of the form The correct time is HH:MM, without a full stop, but then proceed to include a full stop in the first two examples. Which version is correct?

Also additional test case: 07:21 08:39 08:00

Is it allowed to to read the times as command line arguments?

As in whattimeisit 07:21 08:39 08:00 ? Sure!

@Sp3000 Valid point, I've corrected the output format...

CJam, 86 83 77 75 71 bytes
"The correct time is "ea{aea+':f/60fb(f-:+720%!},{];"Look at the sun"}*

Thanks to @jimmy23013 for golfing off 6 bytes from my code.
Try it online in the CJam interpreter.
Test cases
$ cjam time.cjam 05:00 12:00 10:00; echo
The correct time is 05:00
$ cjam time.cjam 11:59 12:30 01:01; echo
The correct time is 12:30
$ cjam time.cjam 12:00 04:00 08:00; echo
Look at the sun

How it works
"The correct time is "
        e# Push that string.
ea      e# Push the array of command-line arguments.
{       e# Filter; for each time T:
  a     e#   Wrap T in an array.
  ea+   e#   Concatenate with the array of all times.
  ':f/  e#   Split each time at the colon.
  60fb  e#   Consider it a base 60 integer.
  (f-   e#   Shift out the converted T and subtract it from the remaining times.
  :+    e#   Add them.
  720%! e#   Push 1 is the sum is 0 modulo 720 and 0 if not.
},      e#   Keep the time iff a 1 has been pushed.

        e# The array on the stack now contains one or three times.

{       e# Reduce; for each time but the first:
  ];    e#   Discard the entire stack.
  "Look at the sun"
        e#   Push that string.
}*      e#

qS/_':f/60fb_f{f-:+720%!,}\"The correct time is "f\2/.e&$("Look at the sun"@?. b implies :i.

"The correct time is "lS/_':f/60fb:T.{Tf-:+720%{}@?}{];"Look at the sun"}*.

You missed the case when x=0

@LakshayGarg: The question says that they each give a different time. That would be false if x = 0.

@Dennis You may be able to reduce it further, the full stop at the end isn't required...

@WallyWest: 4 whole bytes! Thanks for notifying me.

@Dennis NP, oh, and did you see my response about input being accepted as command line arguments?

I might be missing something in the question, either explicit or implicit, that would prevent this from being a problem,  but if I enter "05:00 12:00 11:00", I get an IndexOutOfBoundsException.

@IronFlare: The three times have to be equally spaced. One watch is x minutes behind the actual time. One watch is x minutes ahead of the actual time.

@WallyWest: Yes, my latest revision is taking advantage of that.

@Dennis And there it is-- the part of the question I was missing. Thanks :)

JavaScript (ES6), 164 168 172
For each reading, calc the distance from the other two. The one that have the same distance is what you need. If there is more than one, then you can't tell.

F=s=>(s=s.split(' '))
  .map(x=>([h,m]=x.split(':'),+m+(h%12)*60))
  .map((v,i,z)=>(v+v-z[++i%3]-z[++i%3])%720||'The correct time is '+s[k+=i],k=-2)
[k]||'Look at the sun'

// TEST

out=x=>O.innerHTML += x+'\n';

['12:30 01:01 11:59', '11:50 11:55 12:00', '05:00 12:00 10:00', '12:10 04:10 08:10', '07:00 06:00 08:00']
.forEach(x => out(x + ' -> ' + F(x)))

go=_=>out(I.value + ' -> ' + F(I.value))

<input id=I><button onclick="go()">Test</button>

Should it not give 3:00 for the input 3:00 3:00 3:00. When x=0 :P

@LakshayGarg no. Problem is they each give a different time so x cannot be 0.

With each upvote you get, you should edc65++.

Python 3, 166 163 bytes
L=input().split()
f=lambda x:int(x[:2])*60+int(x[3:])
s=""
for a in L:s=[s,s and"Look at the sun"or"The correct time is "+a][(sum(map(f,L))-3*f(a))%720<1]
print(s)

Uses
      a-b == b-c
<==>  a+c-2*b == 0
<==>  (a+b+c)-3*b == 0

with arithmetic being minutes modulo 720.

Using a similar approach (a+a-b-c==0) I found that sorting is not needed. Did you try to avoid it?

@edc65 I did try to keep a count instead but I think it turned out longer. I also had a+a-b-c initially but that's a lot of calls to f (and pre-list-comp is long)

Python 2, 254 ... 199 207 203 194 200 Bytes
Probably a few ways to shorten this, give me some time..
t=[x.split(':')for x in raw_input().split()]
a,b,c=[int(x[0])*60+int(x[1])for x in t]
print["The correct time is "+':'.join(t[[(c+a)%720%(b/2)<1,2][(a+b)%720%(c/2)<1]]),"Look at the sun"][(a-b)%240<1]

Thanks to Sp3000 helping me fix this.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Random ASCII Art of the Day #5: Diamond Tilings
Mash Up Time!
This is instalment #5 of both my Random Golf of the Day and Optimizer's ASCII Art of the Day series. Your submission(s) in this challenge will count towards both leaderboards (which you can find the linked posts). Of course, you may treat this like any other code golf challenge, and answer it without worrying about either series at all.
Hole 5: Diamond Tilings
A regular hexagon can always be tiled with diamonds like so:

We will use an ASCII art representation of these tilings. For a hexagon of side-length 2, there are 20 such tilings:
   ____     ____     ____     ____     ____     ____     ____     ____     ____     ____
  /\_\_\   /\_\_\   /\_\_\   /\_\_\   /_/\_\   /_/\_\   /\_\_\   /_/\_\   /_/\_\   /_/\_\
 /\/\_\_\ /\/_/\_\ /\/_/_/\ /\/_/\_\ /\_\/\_\ /\_\/_/\ /\/_/_/\ /\_\/\_\ /\_\/_/\ /_/\/\_\
 \/\/_/_/ \/\_\/_/ \/\_\_\/ \/_/\/_/ \/\_\/_/ \/\_\_\/ \/_/\_\/ \/_/\/_/ \/_/\_\/ \_\/\/_/
  \/_/_/   \/_/_/   \/_/_/   \_\/_/   \/_/_/   \/_/_/   \_\/_/   \_\/_/   \_\/_/   \_\/_/
   ____     ____     ____     ____     ____     ____     ____     ____     ____     ____
  /_/_/\   /\_\_\   /_/\_\   /_/_/\   /_/\_\   /_/\_\   /_/_/\   /_/_/\   /_/_/\   /_/_/\
 /\_\_\/\ /\/_/_/\ /_/\/_/\ /\_\_\/\ /\_\/_/\ /_/\/_/\ /_/\_\/\ /\_\_\/\ /_/\_\/\ /_/_/\/\
 \/\_\_\/ \/_/_/\/ \_\/\_\/ \/_/\_\/ \/_/_/\/ \_\/_/\/ \_\/\_\/ \/_/_/\/ \_\/_/\/ \_\_\/\/
  \/_/_/   \_\_\/   \_\/_/   \_\/_/   \_\_\/   \_\_\/   \_\/_/   \_\_\/   \_\_\/   \_\_\/

Given a side length N, you should generate such a tiling for a hexagon of side length N at random. The exact distribution doesn't matter, but each tiling must be returned with non-zero probability.
For N ≤ 4, your submission must produce a tiling within 1 minute at least 80% of the time and at least 80% of the tilings must potentially be generated within 1 minute. Most approaches won't have to worry about this rule (it's very lenient) - this is just to rule out very naive rejection-based algorithms that generate arbitrary strings until one happens to be a tiling.
You might like to know that the total number of possible tilings for given N can be found in OEIS A008793.
You may write a full program or a function and take input via STDIN (or closest alternative), command-line argument or function argument and produce output via STDOUT (or closest alternative), function return value or function (out) parameter.
You must not output more leading spaces than necessary to align the hexagon (that is the left corner of the hexagon should have no spaces in front of it). Each line may contain up to N trailing spaces (not necessarily consistently, so you could e.g. have a rectangular output, printing the hexagon's bounding box).
This is code golf, so the shortest submission (in bytes) wins. And of course, the shortest submission per user will also enter into the overall leaderboard of the series.
Leaderboards
The first post of each series generates a leaderboard.

Random Golf Leaderboard
ASCII Art Leaderboard

To make sure that your answers show up, please start every answer with a headline, using the following Markdown template:
# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
# Ruby, <s>104</s> <s>101</s> 96 bytes

(The language is not currently shown, but the snippet does require and parse it, and I may add a by-language leaderboard in the future.)

Is it just me who keeps seeing the example image in 3D?

@LegionMammal978 No that's perfectly normal. ;) (And is probably also a good way to approach the challenge.)

For N ≤ 4, your submission must produce a tiling within 1 minute at least 80% of the time. too easy: 80% of time the same, basic tiling, otherwise I find another tiling in whatever time I want

@edc65 Good point, let me rephrase that.

CJam, 105 bytes
ri:A" __"e*A,2f*:B,[W1]{J+B:):B,{N1$S*"\/"J%A2*4$-:D*
0{;B{_1&!2mr+J*m1e>D(2*e<}%__:)&}g:B{'_t}/+@J+}*}fJ;

Newline added to avoid scrolling. Try it online
Explanation:
This solution starts each line as a zigzag, then places N underscores on it, based on their position on the previous line and a couple of rules. I got this from a series of observations while looking at the output as a plain 2D matrix of characters:

each line has exactly N underscores
the underscores can be replaced with / or \ to make a perfectly repeating zigzag pattern (/\ in the top half, \/ in the bottom half)
underscores can not touch the sides, and can't be adjacent to another underscore
when going to the next line, the position of each underscore changes by -1, 0 or 1
more than that, /_/ can only change by -1 or 0, and \_\ can only change by 0 or 1
for the initial underscore positions we can either use a "_ " pattern or a " _" pattern, both are fine
the above rules are sufficient to obtain all the tilings

So I decided to implement it by keeping the previous underscore positions, modifying them with a random factor (2 choices for each underscore) and repeating until the rules are satisfied. In the process of optimizing, I switched to underscore positions relative to the left side of the hexagon (not including spaces).
ri:A" __"e*       read the input (A) and generate the top line
A,2f*:B           make an array [0 2 4 ... 2A-2] and store in B
                  these are the initial positions for the underscores
,                 B's length = A, used as the initial number of leading spaces
                  let's call it C
[W1]{…}fJ         for J in [-1 1] (top half, bottom half)
  J+              add J to C
  B:):B           increment the underscore positions (adjustment before each half)
  ,{…}*           repeat A times
    N1$S*         add a newline and C spaces
    "\/"J%        take "\/" and reverse it if J=-1 (zigzag pattern)
    A2*4$-:D*     calculate D=A*2-C and repeat the pattern
    0             dummy value (for the next loop)
    {…}g          do-while
      ;B          pop last value and push B
      {…}%        apply block to each item (say x)
        _1&!      duplicate x and calculate !(x&1) (for /_/ vs \_\)
        2mr+      randomly add 0 or 1
        J*m       multiply by J and subtract from x
        1e>       limit the minimum value to 1
        D(2*e<    and the maximum value to 2*(D-1)
      __:)&       check if the modified array has any adjacent values
    :B            store the new positions in B
    {'_t}/        place underscores over the zigzag pattern
    +@J+          bring C to the top and add J to it
;                 pop C

Old "3D" version, 189 bytes:
ri:A" __"e*aA4*S*aA2**+[0-2XXW1]:C;"/\_\\\/_/":D;A3m*{{C2/.f*:.+~
A(2*+:V;A+:U;2{UI+1$1$=4{_V+D4/I=@=t}/t}fI}:F~}/[0Y1WWW]:C;
"/_/\\\_\/":D;AaA*:B;A{A[_{_BI=e<)mr}fI]:B;{BQ={[PQR]F}fR}fQ}fPN*

Try it online

+1 for awesome work and also because one more vote would put you at 10k rep, but mostly for the awesome work. (Oh hey, look at that. Congrats on 10k :) )

A great analysis on the patterns! I'll use it for my answer.

Python 2, 337 335 324 318 311 300 296 bytes
from random import*
n=input()
R=range(n*2)
b=[]
l=[]
for i in R:o=abs(i-n)-(i<n);b+=[o];l+=[list(' '*o+'\//\\'[i<n::2]*(n*2-o))]
for i in R[:n]:
 o=1;p=n+i*2
 for j in R:r=randint(0,p<n*3+i*2-j);p+=(r or-1)*(o==r);q=p<=b[j];o=r|q;p+=q;l[j][p]='_';b[j]=p+1
for s in[' '*n+'__'*n]+l:print''.join(s)

The idea is to first create a hexagon of diamonds, like this:
  ____
 /\/\/\
/\/\/\/\
\/\/\/\/
 \/\/\/

And then fill it up with downward paths of underscores, like this:
  ____                          ____
 /_/\/\                        /\_\/\
/_/\/\/\    or maybe this:    /\/_/\/\
\_\/\/\/                      \/_/\/\/
 \_\/\/                        \_\/\/

The final result with all paths added would then look something like this:
  ____                          ____
 /_/\_\                        /\_\_\
/_/\/_/\    or maybe this:    /\/_/\_\
\_\/_/\/                      \/_/\/_/
 \_\_\/                        \_\/_/

Quite a bit of code goes into making sure these paths don't go out of bounds or cross eachother.
The ungolfed code:
# Initialize l with all diamonds
blocked = []
l = [[] for _ in range(n*2)]
for i in range(n*2):
    offset = n-i-1 if i<n else i-n
    blocked.append(offset)
    l[i] += ' '*offset + ('/\\' if i<n else '\/')*(2*n - offset)

# Generate the random _'s
for i in range(n):
    oldright = True
    pos = n + i*2
    for j in range(n*2):
        # Go randomly right (true) or left (false), except when you out of bounds on the right side
        right = randint(0, 1) and pos < n*3 + i*2 - j
        if right == oldright:
            pos += 1 if right else -1
        if pos <= blocked[j]:
            right = True
            pos += 1
        l[j][pos] = '_'
        blocked[j] = pos + 1
        oldright = right

# Print the result
print ' '*n + '__'*n
for s in l:
    print ''.join(s)

I think you can shorten randint(0,1)*(p<n*3+i*2-j) to randint(0,p<n*3+i*2-j).

Perl, 174 168 166 161
#!perl -n
for$l(-$_..$_){$t=/_/?join'',map'/_'x($%=rand
1+(@z=/__?/g)).'/\\'.'_\\'x(@z-$%),split/\/\\/:__
x$_;$l>0&&$t!~s!^.(\\.*/).$!$1!?redo:print$"x abs$l-.5,$_=$t.$/}

Try me.

It always seems to generate the same tiling (at least on ideone)

@aditsu, Ideone shows a cached result if you just click on the link. You need to fork to actually run it again.

JavaScript (ES6), 376 416 494
Just to be there ...
This build all the tilings, then choose a random one. Time for the 232848 tilings for N=4 is ~45 sec on my laptop. I did not try N=5.
Being EcmaScript 6 it runs on Firefox only.

F=n=>{
  for(i=s=r=b='';i<n;i++)
    s='\n'+b+'/\\'[R='repeat'](n-i)+'_\\'[R](n)+s,
    r+='\n'+b+'\\/'[R](n-i)+'_/'[R](n),
    b+=' ';
  for(h=[t=0],x=[s+r];s=x[t];t++)
    for(d='';!d[n*3];d+='.')
      if(l=s.match(r=RegExp("(\n"+d+"/)\\\\_(.*\n"+d+"\\\\)/_","g")))
        for(j=2<<l.length;j-=2;h[z]||(h[z]=x.push(z)))
          z=s.replace(r,(r,g,h)=>(k+=k)&j?g+'_/'+h+'_\\':r,k=1);
  return b+'__'[R](n)+x[Math.random()*t|0]
}

function go()
{
  var n = N.value | 0,
  t0 = performance.now(),
  r = F(n),
  t1 = performance.now();

  O.innerHTML = r+'\n\nTime (msec): '+(t1-t0)
}
N: <input id=N value=3><button onclick="go()">GO</button>

In Chromium 42 I get "Uncaught SyntaxError: Unexpected token =>" and "Uncaught ReferenceError: go is not defined"

@aditsu it's ES6, Chrome: no Firefox: yes. Isn't it a well known fact?

I had no idea, I expected Chromium to use the latest and greatest whatever-its-called-apparently-not-javascript. Thanks for explaining.

I ran it now in firefox (31.5.3) and it works for N=1, 2 or 3, but for N=4 it runs for about 10 sec, finishes and doesn't show anything (and there's no error in the console)

@aditsu not sure ... maybe javascript in a sandbox is quietly killed when exceeds the time limit dom.max_script_run_time. It's a global preference in about:config, mine is set to 30.

What do you know.. mine was set to 10 :) Changed it to 60 now and it worked (took about 22 sec).

SmileBASIC, 241 bytes
INPUT N
T=N*2CLS?" "*N;"__"*N
DIM B[T]FOR I=-1TO N-1O=1P=N+I*2FOR J=0TO T-1IF I<0THEN O=ABS(J0N+.5)<<0B[J]=O?" "*O;MID$("\/\",J<N,2)*(T-O)ELSE R=P<N*3+I*2-J&&RND(2)P=P+(R*2-1)*(O==R)A=P<=B[J]R=R||A:P=P+A:LOCATE P,J+1?"_"B[J]=P+1O=R
NEXT
NEXT

Heavily based off of Matty's answer

x86 machine code, 155 bytes
Hexdump:
60 8b fa 51 b0 20 f3 aa 59 51 b0 5f 03 c9 f3 aa
5e b0 0a aa 57 5f 57 b7 2f 8d 14 36 8b ce 2b ca
75 03 80 f7 73 7d 02 f7 d1 51 b0 20 f3 aa 59 8a
c7 aa 8b ee 53 6b d9 fe 8d 5c b3 ff 53 6b de fc
8b 5c 1f fe 8b 47 fe 80 fc 5f 74 23 8a c4 34 73
3c 2f 75 0a 80 ff 5f 74 3e 80 ff 5c 74 37 c1 eb
08 66 81 fb 2f 5c 74 2f 0f c7 f3 d1 eb 72 24 aa
3c 5f 75 01 4d 5b 4b 75 c3 5b 85 ed 75 97 32 c7
3c 73 75 91 b0 20 f3 aa b0 0a aa 4a 75 8e 88 17
5f 61 c3 b3 5f 8a fb 8a c7 eb d4

Explanation:
It's a fastcall function. It takes the size of the hexagon, n, in ecx, and a pointer to output string in edx.
First of all, it prints the first line: a few spaces and a few underscores. Then, it goes into a double loop: outer loop of lines, and inner loop of chars.
Each line starts with a few spaces and a border char (either / or \, depending on whether we are in upper or lower half of the output). Last chars in each line are spaces and a newline byte. The chars in the middle are generated according to the following rules. They guarantee that the output is a valid tiling.

If previous char is _, current char must be the same as the one to the left of it:
(case 1) /_/

(case 2) \_\

If previous char is \ and upper char is _, current char must be _:
 _
\_

If previous and upper chars are \, current char must be equal to upper-left char:
(case 1) _\
         \_

(case 2) /\
         \/

If upper char is / and upper-right char is \, current char must be \:
/\
\

If none of the above holds, choose one of the following two possibilities for current char randomly:

Underscore _
Slash with opposite direction from the previous slash: /\ or \/

To implement these rules, it loads 4 bytes from the upper line into ebx and 4 bytes from current line into eax. Then, ah is the previous char, while al is the one preceding it. Also, bl is the upper-left char, bh is the upper char, and the byte in ebx above bh is the upper-right char. After taking into account the upper-left char, it shifts ebx right by 8 bits so the upper-right char becomes accessible in bh.
To flip the direction of a slash, it does XOR with 0x73.
After finishing a line, it checks two conditions:

Last char must be a slash in the appropriate direction (opposite to the direction of the first slash in line)
There must be exactly n underscores in the line

If either condition is violated, it starts over from first line. So for large n, the output will be very slow, because successful execution requires luck in each line. The following example output for n = 8 takes about a minute to calculate:
        ________________
       /_/_/_/\_\_\_\_\_\
      /_/_/_/\/_/\_\_\_\_\
     /_/_/\_\/\_\/_/_/_/\_\
    /_/_/\/\_\/_/_/_/_/\/_/\
   /_/\_\/\/_/_/_/\_\_\/_/\/\
  /\_\/\_\/_/\_\_\/_/_/_/\/\/\
 /\/_/\/_/\_\/_/\_\_\_\_\/\/\/\
/\/\_\/_/\/_/\_\/_/_/\_\_\/\/\/\
\/\/_/\_\/\_\/\_\_\_\/\_\_\/\/\/
 \/_/\/_/\/\_\/_/_/_/\/_/\_\/\/
  \_\/_/\/\/_/_/_/\_\/_/\/_/\/
   \_\_\/\/_/\_\_\/\_\_\/_/\/
    \_\_\/_/\/\_\_\/_/_/_/\/
     \_\_\_\/\/_/_/_/_/_/\/
      \_\_\_\/_/\_\_\_\_\/
       \_\_\_\_\/_/_/_/_/

Here is assembly source code mixed with disassembly. I took it while stopped at a breakpoint in Visual Studio.
        pushad;
10014190 60                   pushad
        mov edi, edx;
10014191 8B FA                mov         edi,edx

        push ecx;
10014193 51                   push        ecx
        mov al, ' ';
10014194 B0 20                mov         al,20h
        rep stosb;
10014196 F3 AA                rep stos    byte ptr es:[edi]
        pop ecx;
10014198 59                   pop         ecx

        push ecx;
10014199 51                   push        ecx
        mov al, '_';
1001419A B0 5F                mov         al,5Fh
        add ecx, ecx;
1001419C 03 C9                add         ecx,ecx
        rep stosb;
1001419E F3 AA                rep stos    byte ptr es:[edi]
        pop esi; // esi = n
100141A0 5E                   pop         esi

        mov al, '\n';
100141A1 B0 0A                mov         al,0Ah
        stosb;
100141A3 AA                   stos        byte ptr es:[edi]

        push edi;
100141A4 57                   push        edi
    again:
        pop edi;
100141A5 5F                   pop         edi
        push edi;
100141A6 57                   push        edi

        mov bh, '/'; // bh = first char in line
100141A7 B7 2F                mov         bh,2Fh
        lea edx, [esi + esi]; // edx = line index
100141A9 8D 14 36             lea         edx,[esi+esi]

    line_loop:
        mov ecx, esi;
100141AC 8B CE                mov         ecx,esi
        sub ecx, edx;
100141AE 2B CA                sub         ecx,edx
        jnz skip1;
100141B0 75 03                jne         doit+25h (100141B5h)
        xor bh, '\\' ^ '/';
100141B2 80 F7 73             xor         bh,73h
    skip1:
        jge skip2;
100141B5 7D 02                jge         doit+29h (100141B9h)
        not ecx;    // ecx = spaces before and after chars
100141B7 F7 D1                not         ecx
    skip2:

        push ecx;
100141B9 51                   push        ecx
        mov al, ' ';
100141BA B0 20                mov         al,20h
        rep stosb;
100141BC F3 AA                rep stos    byte ptr es:[edi]
        pop ecx;
100141BE 59                   pop         ecx

        mov al, bh;
100141BF 8A C7                mov         al,bh
        stosb;
100141C1 AA                   stos        byte ptr es:[edi]

        mov ebp, esi; // ebp = underscore counter
100141C2 8B EE                mov         ebp,esi

        push ebx;
100141C4 53                   push        ebx
        imul ebx, ecx, -2;
100141C5 6B D9 FE             imul        ebx,ecx,0FFFFFFFEh
        lea ebx, [ebx + 4 * esi - 1]; // ebx = char counter
100141C8 8D 5C B3 FF          lea         ebx,[ebx+esi*4-1]

    i_loop:
        push ebx;
100141CC 53                   push        ebx

        imul ebx, esi, -4;
100141CD 6B DE FC             imul        ebx,esi,0FFFFFFFCh
        mov ebx, [edi + ebx - 2];
100141D0 8B 5C 1F FE          mov         ebx,dword ptr [edi+ebx-2]
        mov eax, [edi - 2];
100141D4 8B 47 FE             mov         eax,dword ptr [edi-2]

        cmp ah, '_';
100141D7 80 FC 5F             cmp         ah,5Fh
        je x_done;
100141DA 74 23                je          doit+6Fh (100141FFh)
        mov al, ah;
100141DC 8A C4                mov         al,ah
        xor al, '/' ^ '\\';
100141DE 34 73                xor         al,73h

        cmp al, '/';
100141E0 3C 2F                cmp         al,2Fh
        jne al_diff;
100141E2 75 0A                jne         doit+5Eh (100141EEh)

        cmp bh, '_';
100141E4 80 FF 5F             cmp         bh,5Fh
        je mov_al_bh;
100141E7 74 3E                je          skip5+22h (10014227h)

        cmp bh, '\\';
100141E9 80 FF 5C             cmp         bh,5Ch
        je mov_al_bl;
100141EC 74 37                je          skip5+20h (10014225h)

    al_diff:
        shr ebx, 8;
100141EE C1 EB 08             shr         ebx,8
        cmp bx, '\\' << 8 | '/';
100141F1 66 81 FB 2F 5C       cmp         bx,5C2Fh
        je mov_al_bh;
100141F6 74 2F                je          skip5+22h (10014227h)

        rdrand ebx;
100141F8 0F C7 F3             rdrand      ebx
        shr ebx, 1;
100141FB D1 EB                shr         ebx,1
        jc mov_al_underscore;
100141FD 72 24                jb          skip5+1Eh (10014223h)

    x_done:
        stosb;
100141FF AA                   stos        byte ptr es:[edi]
        cmp al, '_';
10014200 3C 5F                cmp         al,5Fh
        jne skip5;
10014202 75 01                jne         skip5 (10014205h)
        dec ebp;
10014204 4D                   dec         ebp

    skip5:
        pop ebx;
10014205 5B                   pop         ebx
        dec ebx;
10014206 4B                   dec         ebx
        jnz i_loop;
10014207 75 C3                jne         doit+3Ch (100141CCh)

        pop ebx;
10014209 5B                   pop         ebx
        test ebp, ebp;
1001420A 85 ED                test        ebp,ebp
        jne again;
1001420C 75 97                jne         doit+15h (100141A5h)
        xor al, bh;
1001420E 32 C7                xor         al,bh
        cmp al, '/' ^ '\\';
10014210 3C 73                cmp         al,73h
        jne again;
10014212 75 91                jne         doit+15h (100141A5h)

        mov al, ' ';
10014214 B0 20                mov         al,20h
        rep stosb;
10014216 F3 AA                rep stos    byte ptr es:[edi]

        mov al, '\n';
10014218 B0 0A                mov         al,0Ah
        stosb;
1001421A AA                   stos        byte ptr es:[edi]

        dec edx;
1001421B 4A                   dec         edx
        jne line_loop;
1001421C 75 8E                jne         doit+1Ch (100141ACh)

        mov [edi], dl; // terminating zero byte
1001421E 88 17                mov         byte ptr [edi],dl

        pop edi;
10014220 5F                   pop         edi
        popad;
10014221 61                   popad
        ret;
10014222 C3                   ret

    mov_al_underscore:
        mov bl, '_';
10014223 B3 5F                mov         bl,5Fh
    mov_al_bl:
        mov bh, bl;
10014225 8A FB                mov         bh,bl
    mov_al_bh:
        mov al, bh;
10014227 8A C7                mov         al,bh
        jmp x_done;
10014229 EB D4                jmp         doit+6Fh (100141FFh)

Here is C++ code which I used to develop my assembly code:
#include <stdio.h>
#include <iostream>
#include <random>
#include <set>
#include <string>

#define MY 1

std::random_device rd;
std::mt19937 gen(rd());
std::bernoulli_distribution distr(0.5);

#if MY
__declspec(naked) void __fastcall doit(int, char*)
{
    _asm {
        pushad;
        mov edi, edx;

        push ecx;
        mov al, ' ';
        rep stosb;
        pop ecx;

        push ecx;
        mov al, '_';
        add ecx, ecx;
        rep stosb;
        pop esi; // esi = n

        mov al, '\n';
        stosb;

        push edi;
    again:
        pop edi;
        push edi;

        mov bh, '/'; // bh = first char in line
        lea edx, [esi + esi]; // edx = line index

    line_loop:
        mov ecx, esi;
        sub ecx, edx;
        jnz skip1;
        xor bh, '\\' ^ '/';
    skip1:
        jge skip2;
        not ecx;    // ecx = spaces before and after chars
    skip2:

        push ecx;
        mov al, ' ';
        rep stosb;
        pop ecx;

        mov al, bh;
        stosb;

        mov ebp, esi; // ebp = underscore counter

        push ebx;
        imul ebx, ecx, -2;
        lea ebx, [ebx + 4 * esi - 1]; // ebx = char counter

    i_loop:
        push ebx;

        imul ebx, esi, -4;
        mov ebx, [edi + ebx - 2];
        mov eax, [edi - 2];

        cmp ah, '_';
        je x_done;
        mov al, ah;
        xor al, '/' ^ '\\';

        cmp al, '/';
        jne al_diff;

        cmp bh, '_';
        je mov_al_bh;

        cmp bh, '\\';
        je mov_al_bl;

    al_diff:
        shr ebx, 8;
        cmp bx, '\\' << 8 | '/';
        je mov_al_bh;

        rdrand ebx;
        shr ebx, 1;
        jc mov_al_underscore;

    x_done:
        stosb;
        cmp al, '_';
        jne skip5;
        dec ebp;

    skip5:
        pop ebx;
        dec ebx;
        jnz i_loop;

        pop ebx;
        test ebp, ebp;
        jne again;
        xor al, bh;
        cmp al, '/' ^ '\\';
        jne again;

        mov al, ' ';
        rep stosb;

        mov al, '\n';
        stosb;

        dec edx;
        jne line_loop;

        mov [edi], dl; // terminating zero byte

        pop edi;
        popad;
        ret;

    mov_al_underscore:
        mov bl, '_';
    mov_al_bl:
        mov bh, bl;
    mov_al_bh:
        mov al, bh;
        jmp x_done;
    }
}
#else // not MY
void doit(int n, char* s)
{
    for (int i = 0; i < n; ++i)
        *s++ =' ';
    for (int i = 0; i < n * 2; ++i)
        *s++ ='_';
    *s++ ='\n';
    char* save = s;
again:
    for (int line = 2 * n; line > 0; --line)
    {
        int spaces = n - line;
        char border1 = '\\';
        if (n - line < 0)
        {
            border1 = '/';
            spaces = ~spaces;
        }
        for (int i = 0; i < spaces; ++i)
            *s++ = ' ';
        *s++ = border1;
        int check = n;
        for (int i = 4 * n - 1 - 2 * spaces; i; --i)
        {
            char al = s[-2];
            char ah = s[-1];
            char bl = s[-4 * n - 2];
            char bh = s[-4 * n - 1];
            char bk = s[-4 * n - 0];

            if (ah == '_')
                goto x_done;
            al = ah ^ '/' ^ '\\';
            if (al != '/')
                goto al_diff;
            if (bh == '_')
            {
                al = bh;
                goto x_done;
            }
            else if (bh == '\\')
            {
                al = bl;
                goto x_done;
            }

        al_diff:
            bl = bh;
            bh = bk;
            if (bl == '/' && bh == '\\')
            {
                al = bh;
            }
            else if (distr(gen))
            {
                al = '_';
            }

        x_done:
            *s++ = al;
            if (al == '_')
                --check;
        }
        if (check)
        {
            s = save;
            goto again;
        }
        if (s[-1] != (border1 ^ '/' ^ '\\'))
        {
            s = save;
            goto again;
        }
        for (int i = 0; i < spaces; ++i)
            *s++ = ' ';
        *s++ ='\n';
    }
    *s++ ='\0';
}
#endif // MY

int main(void)
{
    char s[1000];
    std::set<std::string> results;
    while (true)
    {
        doit(3, s);
        if (!results.count(s))
        {
            puts(s);
            results.insert(s);
            std::cout << results.size() << '\n';
        }
    }
}

What are distr and gen?

Oops, I forgot - I had to change random number generation to C++ because rand() wasn't good enough. I added my whole testing environment to make it clearer.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Rearranging Words
You should write a program which receives two strings as input and outputs a sequence of movements which rearrange the first string into the second. You should use as few moves as you can.
Both strings will contain only lowercase letters and the second (goal) string is a permutation of the first (original) one.
Every move is described as char_index:direction where

char_index is the 0-based index of the character in the original (first) string
direction is one of u d l r corresponding to moving the selected character one step up, down, left or right.

You can only move a character to another position if no other character is there. The grid on which you can move the characters is infinite in every direction.
Your goal is to rearrange the letters of the first string so they take up the same area as at start but spell out the second string.
For example a valid move sequence for abc => acb would be 2:d 1:r 2:l 2:u (4 moves):
| abc | ab  | a b | a b | acb |
|     |   c |   c |  c  |     |

Another move sequence for the same input is 2:r 2:d 1:u 1:u 1:r 1:d 1:d 2:l 2:l 2:u (10 moves):
|      |      |      |      |  b   |   b  |      |      |      |      |      |
|      |      |      |  b   |      |      |   b  |      |      |      |      |
| abc  | ab c | ab   | a    | a    | a    | a    | a b  | a b  | a b  | acb  |
|      |      |    c |    c |    c |    c |    c |    c |   c  |  c   |      |

Input

Two strings (original and goal string) containing only the letters [a-z].
The two strings are separated by a newline.

Output

A space separated list of moves.
Each move has the format char_index:direction as described above.

Scoring

Your score is the total number of moves your program uses on the test case inputs. Lower score is better.
In the event of a tie the earlier submission wins.
Your submission is valid only if you ran your program on all the test cases and counted your score.
You can validate your solutions with this python program. Provide input and output filenames as arguments or input and output as stdin (2 lines input and then 1line output).

Test cases
(Test cases are delimited by empty lines.)
ehmwgzcyoaedeyvckivf
chacfveyvwdeyoigezkm

ymnrpltwdyvlgdrgndgx
ggydpnrwgrdyvtnmldxl

gfceetyxotezibswjcdh
oeefgjciehyxswtcdbtz

qdjqiffrqokkitndmufl
oqfrmfudqktikfjqilnd

sxgsugcylgsfgznrktgp
cgsylsgnggkzurgptfxs

izzbcpvwpkackqykurghocpptmbtfcdorlmterhyellurudblqlbldaheorilrfzoonicbfwksdqjjeujvqluktamaurafberdcua
lwrkcbnlllycaorcfklebodkrjuapdbdforulqosofieeqcpzaebuqmuthdurvtpkbmageurlzbiwkaymcvctfhuzprajtlrqjdih

wdbyrdzneneydomipmrjoposrgjvdwmeijrnozapnroqtnayqbfdiojnddcijpdkkmglrwktpsyaoctpenqbmcooksjpeqfrjkgym
wamcedyibsopqckcrdomrzgpirmfrdmdqonmyknpgrbnbkdotrejonyelioaqoksoinzgprtwfednvpjsntjdyoadkwyjjjqpjepm

bwfgxpbxiztsasxkhvdwuhtylvzcmctwxfjahbnbbolcbysbtxfmmrlvptqpvrxfbvfoqjwgrsarvngvigmixlcfpvqyrhcddjiyv
qpjbwvrvgbccptmwxofuqvvltpxacrsanwcmjbkolyhjzbithyqhvxfrsttdmzdbilmhvrfcwrvafygipgbvfnblxvxsybfgsxdxi

gozvqtqxmpjqjftuvbaevdkmjtzylyyjsryfahzsotygxsuzihfwfzfmrvvcaqejpkjqzxyzeoxotdabpmmbknycvvkqlpxpkfory
jvaboapseayzbymyjfvkrozyutvqqsjfxjxfqnttuvejyhqiqzctlfkyxrcmvxjmdooksdvyzrlhpakpbfpzfpgvkgmyzzqmtoxew

ishatpmxygjhxnndyzmmhpjregfmdvtfstgiojcxbstwcghtuckftwrwchepgojxkfgwnynximhnnovhdytmrtiugcmzkwweuudoi
fekopnynwgjvyojnizxcxmustpihhursiwhdhegrcgtkimxutmbgfchoeawmdmwfpkwwyhxdnftthsiuzmtmgtcjvngntrcoxydgj

ehigvxohaivehtdemdjofhkjrxtzsukaccxzyjpufyspfokjxkxztrcmchykhiwfnsgibnjfagntdowkpcogndrafknymzsrkqnelkfrfoltkhfvrwguwpgbkwovfyqpnzmagiakbaduurkgsdeylqemfjklglybdihxptzzxcffqqfoykfrtexhqxdpuwnqjwrnyugkrghwvazaihvjtofrcympsvgaeuorctqmabkokqmwraifdwmphxbbdqjm
gyotpajrrtelqgfezwacfvsinulknmzfpfrplwjxzawkarxkgiookfokjvxbhdqcphohcqmxfdwxksohgrhybzhtrfeksrqedznggxxfamjorwyomaqnliyapdnhvypfkzcdyjknnyxstpyrvggmhxcwrbpfguomksffqyrzhrcmukqaaabaehugifowtpdxiakuhtowvwttnkdbcjtuzfvueieukgdkmfncfwbmjkkdisblrkmhyigqfqvejjqd

lbudhpvhdrlsqmwhsrlzozowdkpesrawprfoqdilpcacboqdxbohnpgeogcqtlhruidvytylckgpdfnfqqvstivzkduttqjgfifcglhajmnzithbyzohiviwuudohppebyqnvhogsqwtywyfegkryxpjphoipiunnhfsbkdsieoqyebluppatgsawnwsaieujsxmanysxcdmjvvymcbqsxiqlihxidajwqrthhjhfncwoxmwumguvhtvxjtgoimd
tqzgsaafjtieekfrsjmxcvqshtxlyltqyoqwdwwowlszlhktiovciigewsdpwxcnhgglwmslcjinnsluxsooimkrpuytupgohfhycdpvcmshxfebqcxpaodiawfsgbwhqahdnvnrvmtqiddmjopdtxhvbwgqvhaihhhkiwjxfnidertpujupoiqrspavyjcqguhdedbpzhnyhhjbuiytqorrgypbbinslmfyqvpykziatulogfdmdqbunpeuzvoo

ryhphfyvyzgaabyqjyjhbsfixgxwdubtlljgjlmzlrbnsmkvjuxgszafnayywvrcbwmttocfppxhbjcqpvyunxkfvinfhnozgvolcowbcppvejiiljiagdmwxvrsblzxsyrsnaivkbnffdduwzkgtpvhmbxavzdcrhpxhnzzcupmekvufvfcfpxnqyoiruofwddwjzihffuvmfeyelwevqbjtsrkujalsambaepbajziptrujjorwhcozmegohho
fafdfvzedydrkyuudnngnzftohdwjrcvyfbtdwbjcmapgmeffpxicrvjuhszpvpplcrqkojvwbatngxizzkrdaehovampctaptrjgsyubawbvuirkvmzoziyozhbhurnflqmplsbhhhllhbxswrxbflxyylruyoftvpwephjowzaiajfehgkyiyobgxemobmjopmnufwswjxpqbsanjjficcmqvxzvfilucbjhcvuwenxzlsvvsxfznyvkjgjagi

zpsnvzghldshvllfrnwjwltecaopsuuucrnsjggcsirymywtmdzpmdoqylbtjavdtvwviohvjtldjdwjoumffmzjjmltcjqtjsryualzqfjdrcunbmquirqcdpcedlyznzkgtrpxldelkmogiutyfjwntjvzfmowcjzlnrivtlajrpowkxykbsxzvhsahsigobkunfxashtcbqmepiyhbuuyfwrbfoknivocyivznnethpcbmztyxfvekqfejcfe
oyetfwkgskcygvszugygtumojmljdcrhnlljgomnrzubcjjlcnyzvzfuyshdchxytbiljjirvvxdkfosfuitdedocwlnsmjmbemowpftabyltjumlwfzfufkurozzichcqwkqasdnimvdbdsjfpmhrkhlnzisvjpapmyrwedcgmudtqtjvtqwluawtqviktxnzyirlspqbnthfxtapbescjvcbohyqejfialrznrojnlfeevxrnpzczvtvyojupw

hhhhyyvnnbqgmiiaaabzoamiudppplwhmjkwjxstcgzprhjknhijcpqqwmcpkbzlngugifmdzyclsokhgogtntheztvwmugitijbmukjllxsgcazdwlfwyzhbkkvhdllfzhpnltfbbijcrpxyjpupqifevxxfbhzqjfjqfgadwgumqxkcocugjdwxkhorjsspdswqlzsdobtjeucpbfthumsscmfwkovwljvunikttgcgcawsevmlfhcpeupwazs
pdqpkzdfmlkjqagwmkyohwdkbchinefzcjmsngxbuptsultmytgagjkfvkscjdlswuujbrachvspfmlfgwplqfipeaobiiupghyoxeswuqschtrccwzpijcbotklzjmtvhgljfzerujmafwvphuhkcfhixacjalxjhlsxshzzdgwiqopxmdvtwhkfzwbgfsknvmgwthogbbvtphuwyqpmtpuqcobwkjihisldelcphylajcdigqbxunzjnmgznnz

How will the strings be input?

@LegionMammal978 It's not code golf, so there's no need to worry or nitpick about such things.

Is there a limit to how slowly the program runs?

@NotthatCharles: I think this is what the third bullet point of the scoring section is about. The way I understand it, your program can be as slow as you want, as long as it has completed all test cases before you post your answer.

Does the program need to be deterministic? For example, could I write a genetic algorithm (which relies on running thousands of random attempts and selectively saving and cross-breeding better attempts)? How should such a submission be scored?

Shouldn't the title be "Rearranging letters" ?

@apsillers Your program should be deterministic but you can use random with a fixed seed making your code deterministic.

CJam, 58,598 58,494 57,898 57,772 57,704 57,680 moves
This approach takes the family of all unordered sets of horizontal moves of minimum cardinality (with some false positives) and adds the minimum number (over all sets) of vertical moves required to avoid superpositions.
If the resulting number of horizontal moves is suboptimal (a false positive), it starts adding more vertical moves until the number of horizontal ones is optimal.
Finally, it orders the generated moves to form a valid sequence.
Try it online in the CJam interpreter.
Animated test cases
Test case 1 | Test case 2 | Test case 3 | Test case 4 | Test case 5
Test case 6 | Test case 7 | Test case 8 | Test case 9 | Test case 10
Thanks to @Doorknob for his help with the animations.
Test cases
$ time for f in xx*; do python3 val.py $f <(cjam prog.cjam < $f); done
move sequence verified with step count 156
move sequence verified with step count 126
move sequence verified with step count 120
move sequence verified with step count 124
move sequence verified with step count 112
move sequence verified with step count 2228
move sequence verified with step count 1862
move sequence verified with step count 2066
move sequence verified with step count 1738
move sequence verified with step count 1932
move sequence verified with step count 8200
move sequence verified with step count 10770
move sequence verified with step count 10360
move sequence verified with step count 8716
move sequence verified with step count 9170

real    0m22.672s
user    0m37.372s
sys     0m1.869s

Pairing characters
Let's analyze the following example (provided by @randomra):
012345678
axabababa
abababaxa

By inspection, it suffices to swap the x with the b that takes its place, which can be done in 16 moves:
1:u 1:r 1:r 1:r 1:r 1:r 1:r 7:d 7:l 7:l 7:l 7:l 7:l 7:l 1:d 7:u

The minimum number of horizontal moves can always be achieved by pairing the nth occurrence of each letter in the first line with the nth occurrence in the second line. However, this is highly suboptimal in this case, since we have to add too many vertical moves to avoid superpositions.
The letter x occurs only once and there is only one optimal choice for pairing the as, so we already know which horizontal moves will be required to get them to their targets.
However, the letter b is trickier:
012345678
   b b b
 b b b

Pairing the bs in order would require moving either the bs itself or the as between them either up or down, since no b can take the place currently occupied by an a.
The right choice is to pair the b at index 7 of line 1 with the b at index 1 of line 2 and not to move the other bs at all. We'll refer to the pairings by their initial and final position, which are [7 1], [3 3] and [5 5] in our example.
But how to find these pairings? In theory, we could just go through all sets of possible pairings for each letter and select the set that requires the least amount of total moves. However, for a letter that occurs n times, there are n! possible sets of pairings, which is impractical.
In this approach, we determine all possible pairings of two letters that, by themselves, won't increase the number of horizontal moves. To achieve this, we take all possible pairs of letters of lines 1 and 2 and, if the letters are the same, replace both by an underscore and determine to number of moves needed to move nth occurrences to nth occurrences.
For our example, this yields the following:
[0 0] [1 7] [2 2] [3 1] [3 3] [4 4] [5 1] [5 3] [5 5] [6 6] [7 1] [7 3] [7 5] [8 8]

As we already knew, the letters at indexes 0, 2, 4, 6 and 8 (the as) should not be moved horizontally and the x has to move from index 1 to index 7.
For the bs, there are several choices to be considered. The b at index 3, for example, can move to index 1 or index 3.
To minimize the number of vertical moves over all possible sets of pairings, we select as many non-overlapping pairings as possible, since moving the corresponding characters to their destinations will require no vertical moves at all.
Finding these proper pairings is a variant of the longest common subsequence problem. and can be done as follows.
We start by replacing the letters of each line by their indexes:
012345678
012345678

The first column ([0 0]) is one of the precomputed pairings, so we select it and remove it from the lines.
We now have
12345678
12345678

The pairing [1 1] is invalid (x would stay in its position). We now remove the first element of the line 1 and the first element of line 2 (not simultaneously) and apply the process exemplified above to
2345678
12345678

and
12345678
2345678

The higher amount of pairings resulting from the two choices will get appended to [0 0].
Thanks to memoization, CJam completes this recursive process almost instantly.
For our example, this selects the following pairings:
[0 0] [2 2] [3 3] [4 4] [5 5] [6 6] [8 8]

This way, all letters except the x and the b that takes its place won't have to move at all.
Moving characters
Consider the input
0123456789AB
xaxxbycydyye
yyabcydxxxey

for which the moves
[1 2] [4 3] [6 4] [7 5] [8 6] [10 11]

get selected. The corresponding characters won't have to move vertically and we can pair the remaining characters in order.
To implement the pairing, we use the same algorithm we have already used to determine the minimum number of horizontal moves.
We start by replacing characters corresponding to selected pairings with underscores:
0123456789AB
x_xx_y___y_e
yy_____xxxe_

Now, we enumerate each character's occurrences on both lines:
['x 0] ['_ 0] ['x 1] ['x 2] ['_ 1] ['y 0] ['_ 2] ['_ 3] ['_ 4] ['y 1] ['_ 5] ['e 0]
['y 0] ['y 1] ['_ 0] ['_ 1] ['_ 2] ['_ 3] ['_ 4] ['x 0] ['x 1] ['x 2] ['e 0] ['_ 5]

Now, we compute the indexes of all pairs in both the second and first line:
[0 7] [1 2] [2 8] [3 9] [4 3] [5 0] [6 4] [7 5] [8 6] [9 1] [10 11] [11 10]

As before, the pair [0 7] means that the character at index 0 has to move to index 7.
We eliminate the pairs that had been selected been selected before and examine the remaining pairs:
[0 7] [2 8] [3 9] [5 0] [9 1] [11 10]

We divide these pairs into two groups, differentiating between characters that move left and those who do not:
[0 7] [2 8] [3 9]
[5 0] [9 1] [11 10]

Now, we move each character from the second group one unit up and then right until it is below its target. To avoid superpositions, we sort the characters by their final positions (rightmost comes first).
Similarly, we move each character from the first group one unit down and then left until it is below its target. Again, we sort the characters by their final positions (leftmost comes first).
With the vertically moving characters out of the way, we can move the characters of the firstly selected pairs to their destinations.
We already know how many times we have to move each character in which direction; what is left to figure out is the correct order of these moves.
There are several ways of doing this. My implementation simply removes all characters that are already at its destination, moves each character one unit towards its destination if that position is not occupied and repeats the process.
For the pairs
[1 2] [4 3] [6 4] [7 5] [8 6] [10 11]

this gives the following move order:
1:r 4:l 6:l 10:r 6:l 7:l 7:l 8:l 8:l

Finally, we move each character that has moved vertically one unit down or up to reach its destination.
False positives
A cornerstone of this approach is the way it differentiates "good" from "bad" pairings. A good pairing, by itself, won't increase the number of horizontal moves.
However, we select several of these pairings to minimize the number of vertical moves. Certain combinations of good pairings can increase the number of horizontal moves, leading to suboptimal results.
The following example illustrates this.
01234567
a a a
   a a a

For this input, we obtain this list of good moves:
[0 3] [0 5] [0 7] [2 3] [2 5] [2 7] [4 5] [4 7]

Indeed, neither [0 5] nor [2 7] is a bad move by itself.
However, if both moves get selected, we are forced to use the paring [4 3], which is a bad move since a goes in the wrong direction.
We define a false positive in the selection of pairings as a set of good moves that force us to select a bad one later.
These false positives seem to be rather uncommon. Of all fifteen test cases, there was only one false positive.
In the eleventh test case, the distribution of the letter h is the following:
 h     h    h        h                                   h  h                                                h                                                    h                    h                  H      H                                      h
                                                            h    h h           h  h   h                                    h                        h                   H            H              h                                              h

The uppercase Hs highlight two good pairings that both get selected and cause the hs between them to make a bad pair.
For the general case, we'd either have to avoid these false positives during the selection process or remove the good pairs that caused them afterwards and repeat the selection.
For the test cases, it suffices to proceed as follows:

After selecting all pairings, count the number of horizontal moves we have to make.
If it is suboptimal, remove each pair of the selection and recount.
If the number of horizontal moves is optimal after removing one of the pairs, remove it permanently.
If no pair can be removed to achieve the minimum number of horizontal moves, give up and keep all original pairings.

Step 4 is never reached for the test cases.
Code
[l:Al:B]    e# Read two lines from STDIN and store them in A and B.
{           e# Define a function:
  {         e#   Define a function:
    {       e#     For each line:
      :Lee  e#       Save the line in L and enumerate its characters.
      {     e#         For each pair (index, character):
        ~_  e#           Dump the pair and copy the character.
        @L< e#           Cut L off at that index.
        e=  e#           Count the occurrences of the same character to its left.
        a+  e#           Push the pair (character, occurrence).
      }%    e#         This turns "aba" into [['a 0] ['b 0] ['a 1]].
    }/      e#
    f{\a#}  e#     Push the indexes of the pair of line 1 in line 2.
    ee      e#     Enumerate them.
            e#     This turns ["aba" "baa"] into [[0 1] [1 0] [2 2]].
  }:I~      e#   Name the function I and execute it.
  ::-:z     e#   Compute the absolute difference of each pair.
  :+        e#   Add those differences.
}:C~        e# Name the function C and execute it.
            e# C counts the minimum number of horizontal moves to get each
            e# character to its destination.
:O;         e# Save the result for the original input in O.

A,2m*       e# Push an array of all pairs of non-negative integers below len(A).
{           e# Filter those pairs:
  :P[AB].=  e#   Save a pair in P and select the corresponding chars of A and B.
  :=        e#   Check if the characters match.
  {         e#   If they do:
     [      e#
       AP0= e#     Push A and the first index of P.
       '_t  e#     Replace the corresponding char of A with an underscore.
       BP1= e#     Push B and the second index of P.
       '_t  e#     Replace the corresponding char of B with an underscore.
     ]      e#
     C      e#     Execute C on the modified lines.
     O=     e#     Check if the minimum over the modified lines matches O.
  }         e#
  0?        e#   Else, push 0.
},          e# If the result was 1, keep the pair.
:M;         e# Save the result in M and pop it form the stack.
            e# M contains all possible pairings of characters of line 1 and line
            e# 2 that do not increase the minimum number of horizontal moves.

[A,,_]      e# Push the array [[0 ... len(A)-1][0 ... len(A)-1]].
Q{          e# Set up a memoized recursive function j:
  _:e&      e#   Check if if both arrays are non-empty.
  {         e#   If they are:
    _0f=:P  e#     Retrieve the first element of each array and save in P.
    M\e=    e#     Check if P belongs to M.
    {       e#     If it does:
      Pa\   e#       Push [P] and swap it with the arrays.
      1f>j  e#       Remove P from the arrays and execute j.
      +     e#       Concatenate [P] and the result of j.
    }{      e#     Else:
      _2,W% e#       Copy the arrays and push [1 0].
      .>    e#       Vectorized tail. Removes the first element of array 1.
      j     e#       Execute j on the result.
      \2,   e#       Swap with the arrays and push [0 1].
      .>    e#       Vectorized tail. Removes the first element of the array 2.
      j     e#       Execute j on the result.
      _,2$, e#       Push the lengths of both results of j.
      <@@?  e#       Select the longer array.
    }?      e#
  }{        e#   Else:
    ;Q      e#     Remove the arrays and push an empty array.
  }?        e#
}j          e# Execute j on the initial arrays.
            e# This pushes a set of non-overlapping pairings of maximal size.

W\+W+       e# Prepend and append -1 (dummy value) to the pairings.
:G,,        e# Save in G and push [0 ... len(G)-1].
{           e# Find in G:
  G\Wt      e#   Replace the element in G at that index with -1.
  W-:H      e#   Remove all -1's and save the result in H.
  z         e#   Zip the array of parings. This groups the indexes of the first
            e#   line in one array and the indexes of the second line in another.
  [AB]\     e#   Push the array of lines.
  .{        e#   Vectorized foreach:
    {'_t}/  e#     Replace the corresponding characters by underscores.
  }         e#
  :T        e#   Save the result in T.
  CO=       e#   Count the minimum number of horizontal moves and compare with O.
}#          e#   Stop if they match.
;           e#   Discard the index returned by {}#.
            e# This saves G itself in H if the number of horizontal moves was
            e# already optimal and discards at most one element of G to achieve
            e# optimality. T now equals [A B], where characters that will
            e# move only horizontally have been replaced by underscores.

TIH-        e# Execute I on T and remove the elements from H.
            e# This pairs all characters that will have to move vertically.
{           e# Sort by the following key:
  _1=       e#   Retrieve the second element (index of line 2).
  \:>       e#   Push 1 if the index of line 1 is bigger than the one of line 2.
  2*(       e#   1 -> 1 and 0 -> -1
  *         e#   Multiply by the index of line 2.
}$          e# This sorts the pairings by direction, then final position.

{           e# For each pair [X Y]:
  _:>:D;    e#   Set D := 1 if X > Y and D :=0 otherwise.
  ~\:I      e#   Save X in I.
  ":d :u "  e#   Push that string.
  3/        e#   Split it into [":d " ":u "].
  f+        e#   Prepend I to both strings.
  Dm>       e#   Swap the order of the array's elements if D == 1.
  ~o        e#   Dump the array and print its second element.
            e#   The first element will be left on the stack. CJam will print it
            e#   after executing the rest of the program.
  \I-z      e#   Compute abs(Y - I).
  ":r :l "  e#   Push that string.
  3/        e#   Split it into [":r " ":l "].
  D=        e#   Retrieve the string at index D.
  I\ +      e#   Prepend I.
  *o        e#   Repeat the string abs(Y - I) times and print.
}/          e#

H{          e# For each pair in H:
  [         e#
    ~\:I    e#   Save the initial position in I.
    I@I-    e#   Subtract the initial position from the final position (D).
    _ga     e#   Push [sign(D)].
    \z*~    e#   Repeat the array abs(D) times and dump it.
  ]         e#
}%          e# The result contains I twice, followed by abs(D) copies of sign(D).

{           e#
  {2>},     e# Filter out elements with length two.
  _         e# Push a copy.
}{          e# While the copy is non-empty:
  _0f=:P;   e#   Save the positions the elements currently occupy in P.
  {         e#   For each array:
    __,(%   e#     Retrieve the first and last element (position, direction).
    :+:J    e#     Add them and save the result in J.
    P&      e#     Intersect with P.
    {       e#     If J is not in P:
      _1=o  e#       Print the character's identifier.
      ':o   e#       Print a colon
      )0>   e#       Retrieve the direction.
      "lr"= e#       Push 'l' or 'r'.
      S+o   e#       Append a space and print.
      0Jt   e#       Save the new position in the array element.
      PJ+   e#       Append the new position to P.
      :P;   e#       Save in P.
    }|      e#
  }%        e#
}w          e#

Wow, So impressive and huge, not reading it...+1 though

+150 in 24 hours, 50 for this answer 100 for the other ;).

Those animations, I also want to know how you did those. Did you have to rewrite the algorithm in JS?

@carusocomputing No, I wouldn't know how to do that. If you click Edit in JSFiddle in the first link, it will lead you to https://jsfiddle.net/gj08tznh/, where you can see the source code. I just plugged the results from CJam in and – with Doorknob's help – animated them with jQuery.

That's insanely cool, the list of moves is an interesting idea; with no 3rd party libs as well! I always forget jQuery can do so much more than make things look pretty.

:-) Thanks in advance for the bounty! Feel free to award it whenever you want; personally, I wouldn't mind sitting in the featured tab for a week. ;)


text:
Translate RoboCritters into Brainf***
RoboCritters (etymology) is a brand new esoteric programming language (don't bother searching for it, I just invented it). It's a variant of Brainfuck (BF), slightly more complex than the usual operator substitution schemes. Every program in RoboCritters is a rectangular grid of text that only contains the seven characters . []/\|, plus newlines to shape the grid.
Example RoboCritters program:
|\/||./|[]||
[..][][]   |
|/\|[..][..]
[..]    \/\/

To translate a RoboCritters program into BF, look at each non-newline character in the grid in the normal reading order (left-to-right then top-to-bottom), e.g. |\/||./|[]||[..][][]   ||/\|[..][..][..]    \/\/.
If the 4×2 section of the grid extending right and down from the current character exactly matches one of the eight robot critters listed below, append the corresponding BF command (><+-.,[]) to the (initially empty) BF program.
If the 4×2 grid section does not match any of the robot critters or goes out of bounds, nothing is added to the BF program.

Joybot, > command:
[..]
\][/

Calmbot, < command:
[..]
/][\

Squidbot, + command:
[..]
//\\

Spiderbot,  - command:
[..]
||||

Bunnybot, . command:
[][]
[..]

Toothbot, , command:
[..]
|/\|

Foxbot, [ command:
|\/|
[..]

Batbot, ] command:
[..]
\/\/

So, reading the example program
|\/||./|[]||
[..][][]   |
|/\|[..][..]
[..]    \/\/

we can see that we first encounter a Foxbot (at column 1, row 1), then a Toothbot (c1,r2), then a Bunnybot (c5,r2), and finally a Batbot (c9,r3). This corresponds to the BF program [,.].
Notice that the Foxbot and Toothbot overlap. This is intentional; robot critters are not interpreted any differently when they overlap.
Challenge
Write the shortest program possible that takes in a RoboCritters program and outputs its BF equivalent. You don't need to run the BF or check that it's valid, only translate the RoboCritters code to BF code.
Details

All input RoboCritters programs will be valid, that is they will be an exactly rectangular block of text only containing the seven characters . []/\|, plus newlines to shape it. The newlines may be in any convenient common representation. You may optionally assume the programs have a single trailing newline.
You must support RoboCritters programs that are smaller than 4×2, including the 0×0 empty (or single newline) program. These all correspond to the empty BF program (the empty string).
The output BF program should be a one-line string only containing the eight BF command characters ><+-.,[]. There may optionally be a single trailing newline.
Take input in any usual way (stdin/text file/command line) and output to stdout or your language's closest alternative.
Instead of a program you may write a function that takes the RoboCritters program as a string and prints or returns the BF program string.

Examples

Input: (variant of example above)
|\/|[][]
[..][][]
|/\|[..]
    \/\/

Output: [,.]
Input: (tests all robot critters)
[..][[[[[..]]. ]|\/|
\][/[..]//\\[..][..]
[..]/][\[][]|/\|[..]
||||/\| [..]|  |\/\/

Output: >+[<,-.]
Input:
[..] [..] [..] [..] [..] [..] [..] [..] |\/| [..] [..] [..] [..] [..] |\/| [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] |\/| [..] [..] [..] [..] [..] [..] [..] [][] [..] [..] [..] [..] [][] [..] [..] [..] [..] [..] [..] [..] [][] [][] [..] [..] [..] [][] [..] [..] [][] [..] [..] [][] [..] [][] [..] [..] [..] [][] [..] [..] [..] [..] [..] [..] [][] [..] [..] [..] [..] [..] [..] [..] [..] [][] [..] [..] [..] [][] [..] [..] [..] [][]
//\\ //\\ //\\ //\\ //\\ //\\ //\\ //\\ [..] \][/ //\\ //\\ //\\ //\\ [..] \][/ //\\ //\\ \][/ //\\ //\\ //\\ \][/ //\\ //\\ //\\ \][/ //\\ /][\ /][\ /][\ /][\ |||| \/\/ \][/ //\\ \][/ //\\ \][/ |||| \][/ \][/ //\\ [..] /][\ \/\/ /][\ |||| \/\/ \][/ \][/ [..] \][/ |||| |||| |||| [..] //\\ //\\ //\\ //\\ //\\ //\\ //\\ [..] [..] //\\ //\\ //\\ [..] \][/ \][/ [..] /][\ |||| [..] /][\ [..] //\\ //\\ //\\ [..] |||| |||| |||| |||| |||| |||| [..] |||| |||| |||| |||| |||| |||| |||| |||| [..] \][/ \][/ //\\ [..] \][/ //\\ //\\ [..]

Output: (BF Hello World program)
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

Input: (no robot critters present)
/\\\[].
]..[..]
\\//||\

Output: (empty string)

Scoring
The shortest submission in bytes wins. (Handy byte counter.) Tiebreaker is highest voted post.

CJam, 86 85 bytes
qN/S4*f+_W<\1>]z:z4few:~"¨Ý³5&ágûò{wÉ](Ý"296b6b"|[\.]/"f=2/4/"><+-.,[]":Ler{L&},

Test it here.
Explanation
qN/    e# Read input and split into lines.
S4*f+  e# Append four spaces to each line. This has two purposes. a) We can later join all
       e# the lines together without worrying about critters appearing across the line
       e# edges because no critter contains spaces. b) It works around a bug in CJam where
       e# the command `ew` crashes when the substring length is longer than the string.
_W<    e# Copy the lines and discard the last one.
\1>    e# Swap with the other copy and discard the first one.
]z     e# Wrap both in an array and zip them up. Now we've got an array which contains
       e# all consecutive pairs of lines.
:z     e# Zip up each of those pairs, such it becomes an array of two-character strings.
       e# We can now find the critters as 4-element subarrays in each of those arrays.
4few   e# Turn each of those arrays into a list of its (overlapping) 4-element subarrays.
:~     e# Flatten those lists, such that we get one huge array of all 4x2 blocks, in order.
"gibberish"296b6b
       e# This is an encoded form of the critters. The above produces a string of the
       e# critters in column-major order, all joined together, where the characters are
       e# represented by numbers 0 to 5.
"|[\.]/"f=
       e# Turn each number into the correct character.
2/4/   e# Split first into columns, then into critters. Now all we need to do is find these
       e# the elements of this array in the processed input.
"><+-.,[]":L
       e# A string of all BF characters in the same order as the critters. Store this in L.
er     e# Do an element-wise replacement. This will leave non-critter blocks untouched.
{L&},  e# Filter the result. The elements are now either characters, or still full 4x2
       e# blocks. We take the set intersection with the array (string) of BF characters.
       e# If the current element is itself a character, it will be coerced into an array
       e# containing that character, such that we get a non-empty intersection. If the
       e# current element is a block instead, if contains arrays itself, so the set
       e# intersection will always be empty.

       e# The resulting array of characters is the desired BF program and will be printed
       e# automatically at the end of the program.

The critters were encoded with this script. I found the base 296 for the encoding with the following, rather naive Mathematica script (which is still running in search for a better base):
b = 256;
While[True,
  If[
    FreeQ[
      d = IntegerDigits[15177740418102340299431215985689972594497307279709, b],
      x_ /; x > 255
    ],
    Print@{b, Length@d}
  ];
  b += 1;
]

JavaScript ES6, 209 198 192 bytes
f=c=>{s=''
b=o=>c.substr(o,4)||1
for(i in c)s+=!~(d='1\\][/1/][\\1//\\\\1||||[][]11|/\\||\\/|11\\/\\/'.replace(/1/g,'[..]').indexOf(b(i)+b(++i+c.search(`
`))))|d%8?'':'><+-.,[]'[d/8]
return s}

The Stack Snippet below contains ungolfed code that you can easily run in any browser.

var f = function(c) {
  var s = '';
  var b = function(o) {
    // If it is looking on the last line, this will return an empty string
    // the second time, which could cause an inaccurate match.
    // `||1` makes it return 1 instead of '', which won't match.
    return c.substr(o, 4) || 1;
  }
  for (var i in c) {
    r = b(i) + b(++i + c.search('\n'));
    d = '1\\][/1/][\\1//\\\\1||||[][]11|/\\||\\/|11\\/\\/'.replace(/1/g, '[..]').indexOf(r);
    s += !~d || d % 8 ? '' : '><+-.,[]' [d / 8];
  }
  return s;
}

// GUI code below
function run(){document.getElementById('s').innerHTML=f(document.getElementById('t').value);};document.getElementById('run').onclick=run;run()
<textarea id="t" cols="30" rows="10">
[..][[[[[..]]. ]|\/|
\][/[..]//\\[..][..]
[..]/][\[][]|/\|[..]
||||/\| [..]|  |\/\/</textarea>
<button id="run">Run</button>