text:
Print a Negative of your Code
Consider a square of printable ASCII characters (code points 0x20 to 0x7E) for side length N, like the following (here, N = 6):
=\
 g \
7
m+y "g
  L ~
e> PHq

We also require each row and each column to contain at least 1 space and 1 non-space character. (The above example satisfies this.)
We define the negative of such a square, to be a square of the same size, where each space is replaced with a non-space and vice versa. E.g., the following would be a valid negative of the above example:
  1234
a b cd
 ZYXWV
   !
{} [ ]
  ?

The choice of non-space characters is irrelevant (as long as they are from the printable ASCII range).
The Challenge
You're to write a program, with square source code with side length N > 1, which prints a negative of itself to STDOUT. Trailing spaces have to be printed. You may or may not print a single trailing newline.
The usual quine rules also apply, so you must not read your own source code, directly or indirectly. Likewise, you must not assume a REPL environment, which automatically prints the value of each entered expression.
The winner is the program with the lowest side length N. In the event of a tie, the submission with the fewest non-space characters in the source code wins. If there's still a tie, the earliest answer wins.

Is a function's return value accepted or should it be printed to STDOUT?

@PaulGuyot For this challenge, please stick to full programs and STDOUT (as it's, loosely speaking, a quine variant).

You should clarify that the board size must be N>0.  I see that your example specifies N>1 (and did you mean N>=1?), but this is not in the rules proper.

@imallett implied by "We also require each row and each column to contain at least 1 space and 1 non-space character". Wait. No. It isn't. Good point. It does imply N==0||N>1, though.

@imallett That is supposed to be part of the rules, not the example (because my definition of negative only applies provided these constraints are fulfilled). Will clarify.

Is a rectangle also a square in your definition?

@jpcooper No, I'm asking for a square with N = width = height.

@MartinBüttner What if each row has m initial non-space characters and n final space characters with (m+n) rows? Is it still not a square by your definition?

@jpcooper Yes, that's a square, but it doesn't satisfy "We also require each row and each column to contain at least 1 space and 1 non-space character." because the first m columns don't contain spaces, and the last n columns don't contain non-spaces.

@MartinBüttner That is indeed true.

Pity that you can't read your own source code, I had a 2x2 answer all revved up.

What about little variation: negative must be a program that print original program? :)

@abc667 like this?

Is it intentional that some lines in the example output are longer than others? The second line is 8 characters long (including the 2 trailing spaces), the fifth line 7 characters (one trailing space). Based on the description, I would have expected all lines to be 6 characters long.

I hope someone will do this in piet.

CJam, 4 x 4 (8 non-spaces)
 L _
{ _
 _ }
_ p

Try it online in the CJam interpreter.
Output
{ _
 _ }
{ _
 _ }

How it works

L pushes an empty array and _ pushes a copy of it.
The block
{ _
 _ }

pushes that block on the stack.
_ pushes a copy of the code block and p prints it, followed by a linefeed.
Finally, the interpreter prints all remaining items on the stack: two empty arrays that do not affect the output, and the original code block.

Alternate version
 L ~
{ _
 p }
_ ~

Try it online in the CJam interpreter.
Output
{ _
 p }
{ _
 p }

How it works

L pushes an empty array and ~ dumps it. The stack is empty again.
The block
{ _
 p }

pushes that block on the stack.
_ pushes a copy of the block and ~ executes the copy.
The _ inside the copy of the block will push a copy of the original block, which p will print, followed by a linefeed.
Finally, the interpreter prints the remaining item on the stack: the original code block.

Perl, 7×7 (42 non-spaces)
for$i(
1..56 )
{$_= $i
%8? $i%
7? $":7
: $/;1;
 print}

Output:
      7
     7
    7
   7
  7
 7
7

This is one of the coolest pieces of code I've seen in a long time.

Straightforward and simple, but quite boring. Still +1.

It would be even more cool if it displayed a 7 made of 7. :)

@A.L Just need 8 more characters (7 spaces and a newline).

CJam, 4X4 (12 10 non-spaces)
 6,
SS +
* 4/
 N*

Output:
0  1
  2
 3
4  5

Previous version with 12 non-spaces:
 4a4
* 4S
** 4
/N*

And the output is
4
 4
  4
   4

As pointed out by Martin, this version has

4 Spaces,
4 *,
4 4,
4 other characters, and
4 4 as the output

;)
Try it online here

It also has 4 upvotes, but I'm about to spoil that for you. Sorry! :-D

Maybe we can get it to 44? +1 :)

sorry for being upvote #13 :P

Keep the pace going till 4^4

Doesn't 4^4 == 0? ;)

Yeah, I don't like the fact that bitwise XOR stole the symbol that should have been used for exponents. Messes up code readability, honestly.

@SuperJedi224 exponentiation is ** and tetration is ***. Having a unique single operator for any meta-operation higher than multiplication is silly :p

@Sparr Depends on the language; actually, I don't know of any with tetration built-in. Personally, I prefer Knuth's Arrow Notation for tetration and beyond.

@SuperJedi I prefer using array notation past exponentiation.

TBF I think past exponentiation, there should just be repeated symbols, but exponentiation should have its own symbol

Marbelous - 16x16
....@0..@1....
@3..0A08..@2  ..
/\--....>1  ..Hp
..@2..\\  =0@3..
ss..//  --\\\\..
@0/\  @1/\Hp..!!
:s  #the-cake-is
  2020#a-pie/lie

Test it here! Spaces as blanks, cylindrical board, and include libraries all must be checked.
Output
              07
            06
          05
        04
      03
    02
  01
01

Explanation
There are two boards here: the main board (shown below), and the ss board, which takes no inputs and outputs two spaces (0x20) to STDOUT.
A blank cell is equivalent to a .., and anything after a # is a comment.

Every tick, ss outputs two spaces to STDOUT.
The green path is a simple loop that outputs a newline (0x0A) at the end of every 7th tick.
The blue path will output the numbers (Hp prints a marble as two hex digits) present in the output, at the end of every 6th tick.
After we have printed 01 once, the loop ends, and moves down the red path, which duplicates this marble.
One duplicate is printed (the second 01), and the other is sent down the black path, which terminates the board at the !! cell. Because of the location of the Hp used in this last print, the 01 appears before the same tick's two spaces, rather than after, the behavior of every other Hp call.

Upvoting for the graphical representation of the source.

Python - 11x11
import re
[print(
    re.sub(
"0",   " ",
bin(x)[
2:].zfill(
11)))for x
in[19,15,
1920,116,
15,1,5,3,
3,3, 67]]

Output
      1  11
       1111
1111
    111 1
       1111
          1
        1 1
         11
         11
         11
    1    11

It's a pretty messy and boring solution, but I just thought I'd show that...

It can be done in Python
If you can compress information about your code shorter than your code, then you can pull off something like this :)

This solution takes advantage of the fact that, if you're within a pair of brackets in Python, then you can split your code over several lines and arbitrarily add spaces without getting an IndentationError. Another way of doing something like this is  by ending the line with a backslash.

Python - 7x7 (37 non-spaces)
print(
'%+7s'
'\n'%1
*6+'%'
'-7s'%
111111
      )

Output
      1
      1
      1
      1
      1
      1
111111

Uses Python's old % string formatting operator to do the job: +7 and -7 take care of right/left justification, and the last space to match the closing parenthesis for print in particular. In preparing the format string, we also have

automatic concatenation of string literals across lines, and
string repetition by multiplication (giving us multiple replacement fields for the price of one)

JavaScript (9x9)
 i=9;q=""
; for(;++
i< 91;){;
var q=q+(
!(i% 10.0
)?1:" ");
;i%9|| (q
+="\n") }
alert(q)

Output
1
 1
  1
   1
    1
     1
      1
       1
        1

Notes
I made and golfed (to the best of my ability) code for a square with diagonal of any size n:
q="";for(i=***n***;++i<***n^2+n+1***;i%***n***||(q+="\n"))q+=i%***n+1***?"0":1

replacing the ***asdf*** numbers with constants depending on the side length n, for example for n=6:
q="";for(i=6;++i<43;i%6||(q+="\n"))q+=i%7?" ":1

But, even though that code is length 46, I couldn't get the constant space to line up with a space in the diagonal of the code until it was as big as a 9x9, with a wasted line (the 5th one)
Edit: Changed to add alert(). Before:
 i=9;q=""
; while((
++ i)<91)
{q= q+""+
""+( "")+
(!((i %10
))?1:" ")
;i%9||( q
+="\n")}

Ahh, yea, oops, I see what you mean. I'm fixing it right now, sorry.

You've got some unitialised global variables over there :P

CJam, 5x5, 12 non-spaces
Not a winner, but I wanted to add a rather small and sparse submission, since most answers just print a diagonal.
 1 ]
D * S
 * 5
/ N *
 1 ;

prints
1 1 1
 1 1
1 1 1
 1 1
1 1 1

Test it here.
The last two characters of the code, don't do anything, so it actually only has 10 bytes of real code. For a smaller grid, I could even reduce it by another two bytes to 8, but that doesn't fit on 3x3, and this code doesn't work for even grid sizes.
How it works:
1]           "Push [1].";
  D*         "Repeat 13 times.";
    S*       "Riffle with spaces.";
      5/     "Split into runs of five elements.";
        N*   "Join those with line breaks.";
          1; "Push and pop a 1. No-op.";

The exploded CJam and Pyth answers are by far my favourite thing on the site. Have an upvote, Reddit-style.

Befunge, 9x9
I have no idea why I did this. It took way too long. I have a massive headache now.
8>v_20gv
v9<^v#<4
1@,/<>^6
v1,*$:<p
->,!-^87
:^*25<^g
_88g,^^4
9vp\v#6<
        @

Output:
        @
        @
        @
        @
        @
        @
        @
        @
$$$$$$$$

Some explanation
The code uses g to read the @ characters from the grid "on the fly" (and also the final space, which is @ / 2), and p to modify the loop to write the last output line.
Every single character on the code is used at some point, either as code or as data (the 9 and the @ on the two last lines).
I basically had to do a lot of workarounds to make the code work. The instruction pointer does multiple intersections during execution, of which some are jumped over. (I couldn't use any instruction there for different directions as they would interfere. There is no NOP.) Elsewhere I either reused the same character or just undid it (see the $: in the middle).
I also did some creative work on the stack:

When the (inner) character writing loop terminates (all spaces done for this line), the stack has n,0. I then have to decrement n. The obvious solution would be $1-, but I managed to shorten it by using !-.
When the (outer) line writing loop terminates (all normal lines printed), the stack has a 0. I then organized code changer (20g46p7g46\p) to use that 0, instead of wasting 2 characters on $0.

Befunge always gets a +1 from me. Nice with the !-; that's something I'd do. Fun fact: In Funge-98, z is a NOP.

@Kasran Yeah. z wasn't listed on the wiki and I used this for coding, which meant any non-command flipped the IP direction. Pretty much had to refactor 70% of the code due to one place that should be NOP.

Well, the advantage of doing that is that your code will run in Befunge-95 (which I don't believe has a non-space NOP) as well as 98; since it's a lot harder to use 95, I've always found those answers extra impressive.

Python 3, 8x8
There are 50 non-space characters and 14 spaces. The last line has one useless character, but everything else is necessary.
(*_,q,n
)=p='''
       p
'''[2:]
print(p
*2+q*7,
n+p*4+p
[0:-1])

Output:
       p
       p
ppppppp
       p
       p
       p
       p
       p

Just tried playing around with (a,*b,c)="12345"... starred assignment is interesting :)

@sp3000 kind of haskell-esque. i use python way more than haskell, how did i not know this

Ruby, 8x8
 (0...8)
. map(){
|x |$><<
32. chr*
x+[x ]*'
'<<32 .\
chr*(7 -
x)+?\n}

Output:
0
 1
  2
   3
    4
     5
      6
       7

CJam, 5X5
SSSS
1N]4
*B11
    S

And the output is
    1
    1
    1
    1
1111

I was this close to 4X4 solution. <sigh> See my other answer
Try it online here

C++, 12x12
Edit: So, I became a little obsessed with this challenge and managed to get it down from 17x17 to 12x12. It took me a little while to realize I could use /**/ as a token delimiter. This code takes advantage of the fact that a line splice still works in Clang with a space after it, though it does give warnings and ruins Xcode's colorization of the code.
#include<c\
stdio>/***/
int/**/mai\
n(){for(in\
t/**/i=0;i\
<12;++i)pr\
intf(i^8?"\
           \
|\n":"~~~~\
~~~~~~~\x2\
0\n");}/**/

Output:
           |
           |
           |
           |
           |
           |
           |
           |
~~~~~~~~~~~
           |
           |
           |

05AB1E, 3x3 (6 non-space bytes)
 3Ð
Λ q
°°

Output:
3
 3
  3

Try it online.
Explanation:
3Ð       # Push three 3s to the stack
  Λ      # Canvas with parameters num; filler; pattern
         #  num: The amount of characters to display (3)
         #  filler: The character to display ('3')
         #  pattern: The available options are single-digit integers in the range [0,7]
         #           indicating the direction to print in.
         #           (Option 3 is a top-left to bottom-right diagonal line)
    q    # Exit the program
°°       # no-ops to complete the pattern

Befunge-98, 8x8 (56 non-spaces [11 nops])
Note: In the interest of good sports-person-ship, this reads its own source via ', making it a cheat-quine to some. Read the debate here.
Program
 07'?>:8v
v y+da:%<
<v ':vj!-
,+# '<zzv
v1#a vj!<
>z,\1 -\v
z>+,$v z<
1_@#:<v -
zzzzzv<z

Output
(
 ,
  &
   %
    $
     #
      "
       !

Explanation
The un-golfed version
07'?>:8%:ad+y-!jv>'n,$v
  !jv   a,\1-\v > 's,
    >         >       v
    v-1_@#:           <

(non-space and space are replaced with 'n and 's for readability sake.)
This solution is based off of the fact that using an index [0,width^2) mod the width of the square can tell you if you are at the end of the row or on the diagonal. Since all spaces are placed along the diagonal, it is easy to tell when to print a non-space!
In Pseudocode
const int WIDTH = 8
push 0    //Because of the way the 'y' instruction works when picking
int row=7 //8-1 rows
int i=63  //Starting at the end allows for the cheaper i != 0
do
{
    pick variable row from the stack bottom + 1//ad+y
    if(i%WIDTH == row)
    {
        print non-space
    }
    else
    {
        print space
        if(i%WIDTH == 0)
        {
            print new-line
            --row
        }
    }
  --i
}
while(i != 0);

Discussion
I'm very proud of it, though I wish I could have made every non-space also a non-nop. I'm also proud that I didn't use the standard Befunge get-increment-put trope! It prints out different symbols for non-space because I had the room for it and didn't want to be boring.
Try it on Windows with BefungeSharp!

CJam, 4 x 4 (8 non-spaces)
 N a
` S
 * N
X $

Try it online in the CJam interpreter.
Output
[ "
 " ]
[ "
 " ]

How it works

N pushes a linefeed as a singleton string. a wraps that string in an array.
` inspects the result, i.e., it pushes a string representation of the array.
This is the result:
["
"]

S* joins the resulting string (array of characters), separating its elements using spaces. In other words, it puts a space character between all pairs of adjacent characters of the string.
This is the result:
[ "
 " ]

N pushes another linefeed.
X$ copies the stack item at index 1 (counting from the top), i.e., the multi-line string.
Finally, the interpreter prints all items on the stack: the original multi-line string, the linefeed and the copy of the multi-line string.

SOGL V0.12, 2x2 (2 non-spaces)
2
 ╚

Try it Here!
Output
 /
/

Explanation
In SOGL all lines except the last are replacing lines - it replaces everywhere in the continuing code the last character of the line with everything before it. SO the 1st line here is replace space with 2 in the next line.
Then the next line - 2╚ gets executed: 2 pushes 2, and ╚ creates a diagonal of size 2.

CBM BASIC v2.0 (8×8)
An improvement over my previous answer, using a completely different approach:
1s=56/8
2?sP7);
3?"?"::
4s=s-+1
5ifsgO2
6?-8^6;
7?sP1):
       8

Output:
       ?
       ?
       ?
       ?
       ?
       ?
       ?
-262144

Ruby, 8x8 7x7
 print(
 (?f+"\
 "*6+?\
 )*6).!
 $><<"\
 f"<<!1
;

Output:
f
f
f
f
f
f
 ffalse

Previous version, 8x8 with 20 spaces:
  puts((
  "ff"+#
  ?\s*6+
  ?\n)*7
  );$><<
  ?\s*2+
  ?f;p:p
.!

Output:
ff
ff
ff
ff
ff
ff
ff
  ffalse

Pushy, 4x4 square
Non-competing as the language postdates the challenge:
Code:
 H32
2 C4
:" }
\o/

Outputs:
d
 d
  d
   d

Try it online!
Because whitespace is irrelevant in Pushy, the code is easily arranged to match the negative of its output. The actual program looks like this:
H      \ Push char 100, 'd'
32 2C  \ Push char 32, a space, and make 2 extra copies
       \ We now have the string 'd   '
4:     \ 4 times do:
  "    \   Print the string
   }   \   Cyclically shift it right, once

Backslashes begin a comment, so the trailing \o/ is just there to complete the negative, and look cool.

Alternatively, for the same score, we can have the following solutions:
Code    Output

 35;    #
3 2j     #
2C 4      #
:"}        #

K 36     #
33 2      #
Ct4        #
 :}"    #

Haskell, 10 × 10
main=let{
0&c='\32'
!c;n&c=c!
'\32'>>(n
-1)&c;a!b
=putStrLn
$(b<$[1..
10])++[a]
}in(9&'*'
         )

Defines a helper function a ! b that prints a line of the form bbbbbbbbba, and a recursive function n & c that prints n lines of the form ccccccccc␣ followed by one line of the form ␣␣␣␣␣␣␣␣␣c.
Uses <$ (fmap const, again) on a range to repeat a character. Note that <$ is only available without imports since GHC 7.10, which post-dates this challenge. I am not entirely sure if this makes this submission noncompeting.
Nothing really exciting with the choice of layout or algorithm here; I didn't have a lot of bytes to spare and it's just fortunate one can get the line breaks to occur around the putStrLn the way they did.

Newer languages/versions no longer need to be marked non-competing.

Vyxal j, 3x3 square
 3ƛ
S ↳
3↲

Try it Online!

Perl, 6x6 (26 non-spaces)
I spent a whlie looking through these and was sure there would be a  Perl solution smaller than 7x7 somehow... A very fun challenge! This solution requires -E.
say+(
$"x5,
"5$/"
)x5,5
x5,$"
     ;

Usage:
perl -E 'say+(
$"x5,
"5\n"
)x5,5
x5,$"
     ;'

Output:
     5
     5
     5
     5
     5
55555

CBM BASIC v2.0 (9×9)
0dA8,7,6
1dA5,4, 3
2dA2,1 ,0
3rEs: rem
4?sP s)::
5:? "*";:
6p =8---s
7 ?sPp):?
 8ifsgO3:

Output:
        *
       *
      *
     *
    *
   *
  *
 *
*

Jelly, 4 x 4 (12 non-spaces)
 4=þ
¢ +⁴
¢+ ⁴
¢ỌY

Try it online!
Output:
!
 !
  !
   !

This was pretty fun.
How it works
 4=þ    Link 1 (nilad): Generate an identity matrix of size 4
¢ +⁴    Link 2 (nilad): Add 16 to above
¢+ ⁴    Link 3 (nilad): Add 16 again
¢ỌY     Main link (nilad): Convert the above to ASCII chars, and join by newline

Easy part: Jelly ignores whitespaces (as long as only one-byte builtins are used).
Hard part: Each line in Jelly is a separate link (or function), so it's not very short to spread a constant statement in multiple lines. Using a string literal is a good candidate, but no idea how to generate the negative.

C (gcc), 7x7 8x8
EDIT: Previous version had incorrect behaviour.
 main(i)
{ for(;i
<9 ;pri\
ntf ("%\
*d%" "*\
c",i, 1,
9-i,10 )
,i++);}

Try it online!

"We also require each row and each column to contain at least 1 space and 1 non-space character." Your first column is missing a non-space character.

@KevinCruijssen Somehow I missed the columns criterion, so they're all wrong. Will remake when I have a real computer at hand.

PHP, 11 x 11 square
 for($x=0;#
 $x<10;$x++
 ){echo('|'
 .#########
 str_repeat
 (chr(32),#
 10)."\n");
 }echo(chr(
 32).'----'
 .'------')
;

Output:
|
|
|
|
|
|
|
|
|
|
 ----------

This was a nightmare. I don't think I can fit any smaller.
Try it online!

JavaScript (SpiderMonkey), 71 bytes
for(i=s
='';71 >
++i;s +=
i%9? i%+
8?' ':+1
:[ '\n']
) ;print
 (s);;;;

Try it online!
Why everyone do LU-RD diag?

brainfuck, 15x15, 112 nonspace
 + + + + + + +
+ [ - > + > + +
 + + + + + + +
+ + + < < ] > +
 + > > + > > +
< < [ < . [ - >
 > + < < ] > >
[ - < < + + + >
 > ] > + + + +
+ + + + + + + +
 + + + + + [ <
] < < < < [ . >
 > + + > > + <
< < < < ] > > >
 + ] a a a a a

Try it online!
++++++++[->+>++++<<]>++>>+>>+<<[    10 32(00)00 01 ; Old didn't care nonspaces
<.[->>+<<]>>[-<<+++>>]>             10 96 01 00(01)       10 96 16 0(-17)
+++++++++++++++++[<]<<<<        (00)10 96 01 00 18       (10)96 16 00 00
[.>>++>>+<<<<<]>>>+]                10 96(02)00 18        10 96(18)00 01

Deadfish~, 10x10 square
 {(icdcccc
 ccccc{dd}
 ddc{d}){i
 ii}ii}cic
 cccccccch
 hhhhhhhhh
 hhhhhhhhh
 hhhhhhhhh
 hhhhhhhhh
h

Outputs
!
!
!
!
!
!
!
!
!
 !!!!!!!!!

Explanation
{           repeat 10 times
(           skip following the first time (if accumulator is 0), so repeat x9
ic          increment (will be 32 once this is run , so 33, then print as '!'
dccccccccc  decrement (to 32) and print 9 times
{dd}dd      decrement to 10 for newline
c{d}        print and decrement to 0
)           end if
{iii}ii     increment accumulator to 32
}           end loop
c           print as character (' ')
iccccccccc  increment and print 9 '!'s
h           stop the program, anything after this is junk

Try it online!

authors: วิลัย สิทธินอก


text:
RNA to Protein Translation
RNA, like DNA, is a molecule found in cells encoding genetic information. It consists of nucleotides, which are represented by the bases adenine (A), cytosine (C), guanine (G) and uracil (U).* A codon is a sequence of three nucleotides.
Proteins are large molecules which perform a vast array of functions, such as keratin which is found in hair and nails and hemoglobin which carries oxygen in blood cells.  They are made up of amino acids, which are encoded as codons in RNA molecules. Sometimes different codons may encode for the same amino acid. Each amino acid is commonly represented by a single letter, for example H stands for histidine.
Given a sequence of ACGU, can you translate it into the corresponding protein string?
* DNA consists of ACGT, where the T is thymine. During DNA to RNA transcription, thymine is replaced by uracil.

Input
Input will be a single string consisting of only the characters ACGU in upper case. You may write either a function or a full program for this challenge.
Output
You may choose to output via either printing or returning a string (the latter choice is only available in the case of a function).
Translation should begin at a start codon (AUG, represented as M) and end at a stop codon (one of UAA, UAG or UGA, represented as *). There are four cases where input may be invalid:

The input does not begin with a start codon
The input does not end with a stop codon
The input's length isn't a multiple of 3
The input contains a stop codon somewhere other than at the end

In all of these cases, Error should be outputted. Note that, unlike stop codons, start codons may appear after the start of the string.
Otherwise, you should convert each codon into its respective amino acid via the following RNA codon table:
* UAA UAG UGA
A GCU GCC GCA GCG
C UGU UGC
D GAU GAC
E GAA GAG
F UUU UUC
G GGU GGC GGA GGG
H CAU CAC
I AUU AUC AUA
K AAA AAG
L UUA UUG CUU CUC CUA CUG
M AUG
N AAU AAC
P CCU CCC CCA CCG
Q CAA CAG
R CGU CGC CGA CGG AGA AGG
S UCU UCC UCA UCG AGU AGC
T ACU ACC ACA ACG
V GUU GUC GUA GUG
W UGG
Y UAU UAC

...and output the translated string.
Examples
Invalid cases:
<empty string> -> Error
AUG -> Error
UAA -> Error
AUGCUAG -> Error
AAAAAAA -> Error
GGGCACUAG -> Error
AUGAACGGA -> Error
AUGUAGUGA -> Error
AUGUUUGUUCCGUCGAAAUACCUAUGAACACGCUAA -> Error

Valid cases:
AUGUGA -> M*
AUGAGGUGUAGCUGA -> MRCS*
AUGGGUGAGAAUGAAACGAUUUGCAGUUAA -> MGENETICS*
AUGCCAGUCGCACGAUUAGUUCACACGCUCUUGUAA -> MPVARLVHTLL*
AUGCUGCGGUCCUCGCAUCUAGCGUUGUGGUUAGGGUGUGUAACUUCGAGAACAGUGAGUCCCGUACCAGGUAGCAUAAUGCGAGCAAUGUCGUACGAUUCAUAG -> MLRSSHLALWLGCVTSRTVSPVPGSIMRAMSYDS*
AUGAAAAACAAGAAUACAACCACGACUAGAAGCAGGAGUAUAAUCAUGAUUCAACACCAGCAUCCACCCCCGCCUCGACGCCGGCGUCUACUCCUGCUUGAAGACGAGGAUGCAGCCGCGGCUGGAGGCGGGGGUGUAGUCGUGGUUUACUAUUCAUCCUCGUCUUGCUGGUGUUUAUUCUUGUUUUAA -> MKNKNTTTTRSRSIIMIQHQHPPPPRRRRLLLLEDEDAAAAGGGGVVVVYYSSSSCWCLFLF*

Edit: Added more test cases
Scoring
This is code golf, so the code in the fewest bytes wins.
Note: I'm no expert in molecular biology, so feel free to correct me if I've misstated anything :)

A proper translator should be able to find the open reading frame in any string, not just those that start with AUG!

@canadianer Ahaha yeah I initially considered that, but I didn't want to make the question too complicated by bringing in open reading frames (or even translating multiple proteins from a single string) :)

The empty string would be a useful test case, because it will break some approaches for testing that the decoded sequence starts with M and ends with *.

@PeterTaylor Added, along with a few more short test cases :)

If you wanted to be a real pain, you could use DNA instead of RNA, so you have backwards reading frames too.

CJam (97 93 92 91 bytes)
q"GACU"f#3/{4b"GGEDAAVVRSKNTTMIRRQHPPLLWC*YSSLF"{_s"MW""I*"er}%=}%s_'*/(1<"M"=*Qa=\"Error"?

This is a port of my GolfScript solution with a slightly tweaked hash function because to my surprise one thing which CJam hasn't borrowed from GolfScript is treating strings as arrays of integers.
6 bytes saved thanks to suggestions by Optimizer (including two bytes from something which I thought I'd tried and didn't work - huh).

q"GACU"f#3/{4b"GGEDAAVVRSKNTTMIRRQHPPLLWC*YSSLF"{_s"MW""I*"er}%=}%s_'*/(1<"M"=*Q="Error"@? - 90

@Optimizer, some of that seems to be an improvement. However, it gives a runtime error, and the comparison to Q rather than [Q] is just incorrect.

you have not copied the code correctly, when the code spans multiple lines in comments, it gets a weird unicode character at the line break. You will have to manually type the code urself then. 2. See the logic, it has been altered to correctly work, thus [Q] to Q change is correct.

@Optimizer, try test case AUGUAGUGA

Ah okay. Still [Q] -> Qa

You can always convert a string to an array with :i

@Ypnypn, thanks. It turns out that {i)7&2/}% is one char worse than "GACU"f#, but I'll bear it in mind for future golfing.

JavaScript (ES6) 167 177 chars encoded in UTF8 as 167 177 bytes
... so I hope everyone is happy.
Edit In fact, no need for a special case for last block too short. If the last 2 (or 1) chars are not mapped, the result string does not end with '*' and that gives error anyway.
F=s=>/^M[^*]*\*$/.test(s=s.replace(/.../g,x=>
"KNKNTTTTRSRSIIMIQHQHPPPPRRRRLLLLEDEDAAAAGGGGVVVV*Y*YSSSS*CWCLFLF"
[[for(c of(r=0,x))r=r*4+"ACGU".search(c)]|r]))?s:'Error'

Explained
Each char in a triplet can have 4 values, so there are exactly 4^3 == 64 triplets. The C function map each triplet to a number between 0 and 63. No error check needed as input chars are only ACGU.
C=s=>[for(c of(r=0,s))r=r*4+"ACGU".search(c)]|r

Each triplet maps to an aminoacid identified by a single char. We can encode this in a 64 character string. To obtain the string, start with the Codon Map:
zz=["* UAA UAG UGA","A GCU GCC GCA GCG","C UGU UGC","D GAU GAC","E GAA GAG"
,"F UUU UUC","G GGU GGC GGA GGG","H CAU CAC","I AUU AUC AUA","K AAA AAG"
,"L UUA UUG CUU CUC CUA CUG","M AUG","N AAU AAC","P CCU CCC CCA CCG","Q CAA CAG"
,"R CGU CGC CGA CGG AGA AGG","S UCU UCC UCA UCG AGU AGC","T ACU ACC ACA ACG"
,"V GUU GUC GUA GUG","W UGG","Y UAU UAC"]
a=[],zz.map(v=>v.slice(2).split(' ').map(x=>a[C(x)]=v[0])),a.join('')

...obtaining "KNKNTTTTRSRSIIMIQHQHPPPPRRRRLLLLEDEDAAAAGGGGVVVV*Y*YSSSS*CWCLFLF"
So we can scan the input string and use the same logic of the C function to obtain the code 0..63, and from the code the aminoacid char. The replace function wil split the input string in 3 chars blocks, eventually leaving 1 or 2 chars not managed (that will give an  invalid result string, not ending in '*').
At last, check if the encoded string is valid using a regexp: it must start with 'M', must not contain '*' and must end with '*'
Test In FireBug/FireFox console
;['AUGCUAG','GGGCACUAG','AUGAACGGA','AUGUAGUGA','AAAAAAA',
'AUGUUUGUUCCGUCGAAAUACCUAUGAACACGCUAA',
'AUGAGGUGUAGCUGA','AUGCCAGUCGCACGAUUAGUUCACACGCUCUUGUAA',
'AUGCUGCGGUCCUCGCAUCUAGCGUUGUGGUUAGGGUGUGUAACUUCGAGAACAGUGAGUCCCGUACCAGGUAGCAUAAUGCGAGCAAUGUCGUACGAUUCAUAG']
.forEach(c=>console.log(c,'->',F(c)))

Output
AUGCUAG -> Error
GGGCACUAG -> Error
AUGAACGGA -> Error
AUGUAGUGA -> Error
AAAAAAA -> Error
AUGUUUGUUCCGUCGAAAUACCUAUGAACACGCUAA -> Error
AUGAGGUGUAGCUGA -> MRCS*
AUGCCAGUCGCACGAUUAGUUCACACGCUCUUGUAA -> MPVARLVHTLL*
AUGCUGCGGUCCUCGCAUCUAGCGUUGUGGUUAGGGUGUGUAACUUCGAGAACAGUGAGUCCCGUACCAGGUAGCAUAAUGCGAGCAAUGUCGUACGAUUCAUAG -> MLRSSHLALWLGCVTSRTVSPVPGSIMRAMSYDS*

Nice idea! Was just thinking of doing this. You beat me to it!

C,190 bytes (function)
f(char*x){int a=0,i=0,j=0,s=1;for(;x[i];i%3||(s-=(x[j++]=a-37?a-9?"KNRSIITTEDGGVVAA*Y*CLFSSQHRRLLPP"[a/2]:77:87)==42,x[j]=a=0))a=a*4+(-x[i++]/2&3);puts(*x-77||i%3||s||x[j-1]-42?"Error":x);}

199 194 bytes (program)
a,i,j;char x[999];main(s){for(gets(x);x[i];i%3||(s-=(x[j++]=a-37?a-9?"KNRSIITTEDGGVVAA*Y*CLFSSQHRRLLPP"[a/2]:77:87)==42,x[j]=a=0))a=a*4+(-x[i++]/2&3);puts((*x-77||i%3||s||x[j-1]-42)?"Error":x);}

Saved a few bytes by improving hash formula.
Here's a fun test case:
AUGUAUCAUGAGCUCCUUCAGUGGCAAAGACUUGACUGA --> MYHELLQWQRLD*

Explanation
The triplet of letters is converted to a base 4 number. Each letter is hashed as follows.
x[i]       ASCII code       Hashed to (-x[i]/2&3)
A        64+ 1  1000001            00
G        64+ 7  1000111            01
U        64+21  1010101            10
C        64+ 3  1000011            11

This gives a number in the range 0..63. The idea now is to use a lookup table similar to the ones used by edc65 and Optimizer. However, the hash is designed so that G and A are next to each other and U and C are next to each other.
Looking at the table at https://en.wikipedia.org/wiki/Genetic_code#RNA_codon_table, we see that with the letters ordered in this way, generally the last bit can be ignored. Only a 32-character lookup table is needed, except in two special cases.
See below first two letters, and corresponding amino acids (where 3rd letter is G/A, and where 3rd letter is U/C). Corrections for the two special cases that do not fit the 32-character table are hardcoded.
     A/G U/C          A/G U/C            A/G U/C         A/G U/C
AAX> K   N       AGX> R   S         AUX> I   I      ACX> T   T
GAX> E   D       GGX> G   G         GUX> V   V      GCX> A   A
UAX> *   Y       UGX> *   C         UUX> L   F      UCX> S   S
CAX> Q   H       CGX> R   R         CUX> L   L      CCX> P   P

Corrections for special cases (where last bit cannot be ignored)
AUG 001001=9 -->  M
UGG 100101=37-->  W

Commented code
In golfed version the i%3 code is in the increment position of the for bracket, but it is moved into a more readable position in the commented code.
a,i,j;char x[999];                                                             //Array x used for storing both input and output. i=input pointer, j=output pointer.
main(s){                                                                       //s is commandline string count. if no arguments, will be set to zero. Will be used to count stops.
  for(gets(x);x[i];)                                                           //Get a string, loop until end of string (zero byte) found
    a=a*4+(-x[i++]/2&3),                                                       //Hash character x[i] to a number 0-3. leftshift any value already in a and add the new value. Increment i.
    i%3||(                                                                     //if i divisible by 3,
      s-=(x[j++]=a-37?a-9?"KNRSIITTEDGGVVAA*Y*CLFSSQHRRLLPP"[a/2]:77:87)==42,  //lookup the correct value in the table. for special cases a=24 and a=32 map to 'M' and 'W' (ASCII 77 and 87). If character is '*' (ASCII42) decrement s.
      x[j]=a=0                                                                 //reset a to 0. clear x[j] to terminate output string.
    );
  puts((*x-77||i%3||s||x[j-1]-42)?"Error":x);                                  //if first character not M or i not divisible by 3 or number of stops not 1 or last character not * print "Error" else print amino acid chain.
}

If only there was an O! I added a test case for MGENETICS* though, because it's the most thematic word I could make :P

CJam, 317 121 104 bytes
q3/{{"ACGU"#}%4b"KN T RS IIMI QH P R L ED A G V *Y S *CWC LF"S/{_,4\/*}%s=}%_('M=\)'*=\'*/,1=**\"Error"?

This can still be golfed further.
Updated the mapping mechanism to the one used in edc65's answer.
Even though I came up with this on my own, he beat me to it :)
UPDATE : Shortened the codon table map by observing the pattern in it.
Try it online here

This breaks if the input is the empty string.

@PeterTaylor A rule which was added on your suggestion after the answer was posted ;) . I will update the code soon.

It wasn't a rule that was added, it was a test case which was already implicitly required by the rules.

GolfScript (103 bytes)
{)7&2/}%3/{4base'GGEDAAVVRSKNTTMIRRQHPPLLWC*YSSLF'{..'MW'?'I*'@),+=}%=}%''+.'*'/(1<'M'=*['']=*'Error'or

Online demo (NB doesn't include the two largest test cases because it needs to run in 15 seconds).
Dissection
As Steve Verrill pointed out in the sandbox, the lookup table can be reduced to 32 elements plus two special cases. It turns out that the special cases both involve characters (M and W respectively) which only occur once, and with the right mapping of the characters to base 4 digits it's possible to build the full 64-element lookup table from the 32 elements by doing a duplicate-and-tr:
'GGEDAAVVRSKNTTMIRRQHPPLLWC*YSSLF'  # 32-element lookup table
{                                   # Map over the 32 elements...
  .                                 #   Duplicate the element
  .'MW'?'I*'@),+=                   #   Apply tr/MW/I*/ to the duplicate
}%

Then once we've done the decode, the validation allows for many approaches. The shortest I've found is
.'*'/       # Duplicate and split the copy around '*' retaining empty strings
(1<'M'=*    # Pull out the first string from the split (guarantee to exist even if input is
            # the empty string); if it starts with 'M' leave the rest of the split intact;
            # otherwise reduce it to the empty array
['']=       # Check whether we have ['']. If so, the split produced [prefix ''] where
            # prefix begins with 'M'. Otherwise we want an error.
*           # If we have an error case, reduce the original decoded string to ''
'Error'or   # Standard fallback mechanism

1 byte. Challenge accepted!

@Optimizer, a straight translation to CJam will save a good few bytes because it has a lot of relevant built-ins.

My hashing function is 57 bytes long, while yours is 52. So I can only see at most 5 bytes saving ...

I'm glad my comment in the sandbox was useful. I hoped it might be possible to use the fact that M was one of the special cases to test for a valid start, but it hasn't worked out that way. There are still 8 pairs of identical letters in that string. I wonder if they can be compressed as lowercase letters: g-->GG a-->AA etc. If decompression can be achieved in under 8 characters it would be worthwhile.

Python, 473 bytes
t={'U(A[AG]|GA)':'*','GC.':'A','UG[UC]':'C','GA[UC]':'D','GA[AG]':'E','UU[UC]':'F','GG.':'G','CA[UC]':'H','AU[UCA]':'I','AA[AG]':'K','(UU[AG]|CU.)':'L','AUG':'M','AA[UC]':'N','CC.':'P','CA[AG]':'Q','(CG.|AG[AG])':'R','(UC.|AG[UC])':'S','AC.':'T','GU.':'V','UGG':'W','UA[UC]':'Y'}
import re
i=raw_input()
a=''
for x in[i[y:y+3]for y in range(0,len(i),3)]:
 a+=[t[u]for u in t.keys()if re.match(u, x)][0]
print["Error",a][all((a[0]+a[-1]=="M*",len(i)%3==0,not"*"in a[1:-1]))]

Python 2, 370 358 354 bytes
This is a very straight forward approach using no compression, just trying to pack the information quite densly:
s=lambda x:x and[x[:3]]+s(x[3:])or[]
def f(I):O=''.join(d*any(0==x.find(p)for p in e)for x in s(I)for d,e in zip('*ACDEFGHIKLMNPQRSTVWY',map(s,'UAAUAGUGA,GC,UGUUGC,GAUGAC,GAAGAG,UUUUUC,GG,CAUCAC,AUUAUCAUA,AAAAAG,UUAUUGCU,AUG,AAUAAC,CC,CAACAG,AGAAGGCG,AGUAGCUC,AC,GU,UGG,UAUUAC'.split(','))));return['Error',O][len(I)%3==0==len(O)-O.find('*')-(O[0]=='M')]

Edit: Shaved off a few characters following xnor's suggestion.

I believe you can write s shorter recursively as s=lambda x:x and[x[:3]]+s(x[3:]).

@xnor Great, I didn't think of that. It does not quite work like that, because at the end of the recursion it will output an empty string not an empty list. But with four more character I can make it work. Thanks!

Scala (317 chars)
def g(c:Char)="ACGU"indexOf c;def h(s:String,i:Int)=g(s(i))*16+g(s(i+1))*4+g(s(i+2));def p(a:Int)=a!=48&&a!=50&&a!=56;def f(s:String)=if(s.length%3!=0||h(s,0)!=14||p(h(s,s.length-3)))"Error"else{var r="";for(i<-0 to s.length-3 by 3)r+="KNKNTTTTRSRSIIMIQHQHPPPPRRRRLLLLEDEDAAAAGGGGVVVV*Y*YSSSS*CWCLFLF"charAt h(s,i);r}

The main function is f. Of course, a better choice would be to return an Option[String].

JavaScript (ES6), 143 bytes
s=>/^M\w*\*$/.test(s=s.replace(/.../g,c=>"PVLVLHDVLGRGRAPGR*KYNVL*KTSTSGRTSILIFYNMLR*SCTSRWEQDHIFEQPAPASC.A"[parseInt(c,36)%128%65]))?s:'Error'

Try it online!

source: Stack Exchange

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

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

sort: votes


text:
Decode MD5, Brute Force
The Challenge
Create a program that brute-force* decodes the MD5-hashed string, given here:
92a7c9116fa52eb83cf4c2919599c24a which translates to code-golf
The Rules

You may not use any built-in functions that decode the hash for you if
the language you choose has such.
You may not use an online service to decode the hash for you.
This is code-golf, the program that accomplishes
the task in the shortest amount of characters wins.

Good luck. May the brute-force be with you.
*Brute-Force definition: looping from a-zzz.. including abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=[]\;',./~!@#$%^&*()_+{}|:"`<>? in a string, hashing it, and testing it against the hash given until the correct string that has been hashed has been found. Print the string to the program's output stream.

Interesting challenge. Just have one doubt: Will you hash any character or the input is restricted to a maximum length and/or specific chars?

@IsmaelMiguel well, typically brute force is a-zzzz.. and along the way it finds the answer, so I'll say stick with general ascii. Sorry if that didn't answer your question, I didn't particularly understand it

The term "brute force" is not sufficiently precise unless you state the search space, and (for example) it's not equally difficult to search all nine-character strings as to search all strings of increasing length.

If you want from a-zzzz...., I give you a solution in less than 5 seconds. If you want ALL ASCII chars, it will take some time. You forgot to mention the winning criterion (e.g.: shortest number of chars or bytes).

@IsmaelMiguel a-z, numbers, symbols, etc. Criteria: The Rules #3

I sense an APL solution with around 12 characters.

Are we allowed to use an MD5 library function? It isn't clear what "such a task" refers to in rule 1.

@MtnViewMark edited the rules :D

@parzivail - Ah... hmm... well... I don't think any language or library has such a function! It's sort of the point of MD5 hashes that reversing them is prohibitive to the point of not being useful.  But okay, so Rule 1 prohibits something that doesn't exist.

@MtnViewMark you never know. someone'd probably go and look for a language that has one just to make a short script...

@MtnViewMark Thanks for the comments. I took the first rule to imply we had to implement the algorithm in code ourselves!

Haskell, 101 characters
import Data.Hash.MD5
main=interact$ \m->head.filter((==m).md5s.Str)$iterate([' '..'~']:)[]>>=sequence

Use it like so:
& ghc -O2 -o brute 42043-BruteForce.hs
& echo -n c-g | md5
bc098aea57599de26c8f17a9edbd492e
& echo -n bc098aea57599de26c8f17a9edbd492e | ./brute
c-g

This requires the common package MissingH.

How long does it take to decrypt the given hash value?

@Jakube - Approximately 282,512 years! I seriously doubt that code here could ever complete the task before the computers they were running on failed! Testing up through all 9 character strings (with a 95 character alphabet) requires ~6x10^17 test cases! The code above compiled -O2, does ~71k tests / second. Clearly, even if you could generate and hash 100x faster, it would still take millenia!

Also, please note: You can't decrypt a hash value. All you can do is find strings that hash to the same value.

PHP (155)
<?$a=[];function r($s){for($c=32;$c<127;$c++){$k=$s+chr($c);md5($k)=="92a7c9116fa52eb83cf4c2919599c24a"?die($k):array_push($a,$k)}r(array_shift($a))}r('');

Ungolfed:
<?
$a=[];
function r($s){
    for($c=32;$c<127;$c++){
        $k=$s+chr($c);
        md5($k)=="92a7c9116fa52eb83cf4c2919599c24a" ? die($k) : array_push($a,$k);
    }
    r(array_shift($a));
}
r('');

What it does is define an empty array $a, which will be our operations-to-do-later array. r is a recursive function and $s is the current string we're working with. We begin with an empty string, and loop through all the characters noted above, which are ASCII 32 to 127, and checking them all. While that happens, all of those are pushed onto the end of the array. Then, when all of the 1-length strings are done and all of them are put into the array, we now call r again with the first element in the array. Then, $s will be set to ASCII 32, and it will loop through 2 character strings that start with that character, checking them all and putting them at the end of the array. Since they are at the end, the next call to r will check ASCII 33 rather than them, since it is now the first one in the array. This prevents an infinite loop from occuring where it checks one ASCII 32 and then 2 ASCII 32's and then 3 ASCII 32's... etc.

This code would run out of memory before getting through all five character strings!

@MtnViewMark You can increase the memory limit.

@IsmaelMiguel - Do you have 40GB of RAM? That is how many characters would be needed for get through all 5 character strings. At 6 characters, you'll need 6.5TB of memory... I doubt any system has that much swap space.  Storing all 8 character strings, needed before you can get to "code-golf", you'll need 53 PetaBytes of storage. That's almost half the size of the largest storage arrays ever built.

@MtnViewMark Considering that such a small code needs such a big amount of memory is quite remarkable! I've never seen a code-golf solution being downvoted for being impractical. Give the man an upvote. He had the effort to put such a code.

@MtnViewMark - Yea, I thought of another way but decided that this way would be the shortest to write. I expected it to take up a lot of memory, but didn't expect it to take that much!

I didn't downvote - honest!

Python (182 characters)
import sys,string as c,hashlib as h,itertools as i
m=sys.stdin.read()
j=''.join
print(next(j(v)for n in i.count()for v in i.product(*n*(c.printable,))if h.md5(j(v)).hexdigest()==m))

Example:
$ echo -n Hi! | md5sum
5360706c803a759e3a9f2ca54a651950  -
$ echo -n 5360706c803a759e3a9f2ca54a651950 | python2.7 decode.py
Hi!

The itertools module does most of the work, with .count() responsible for gradual escalation. The nested generator expression is filtered until we get a match on the MD5 hash.

You can import md5 and use md5.new instead of hashlib.md5.

177 bytes

bash - about 105 characters, not the greatest at golfing bash scripts!
Requires makepasswd and openssl.
until [ "$Y" = "$3" ]
do
    X=($(makepasswd --string=$1 --chars=$2))
    Y=($(echo -n $X | md5sum))
done
echo $X

You use it by supplying three arguments: ./reverse-md5 character-set length-of-password md5-hash-to-match, e.g.:
$ ./reverse-md5 'ab' 4 54a8723466e5d487247f3d93d51c66bc
abba

Hoorah, have found the name of an obscure Swedish pop band!
Note that this is a directed attack in that you have some idea of the characters used and the length of the password.
So you could use the script in a directed attack as follows to complete the challenge:
$ ./reverse-md5 'cdefglo-' 9 92a7c9116fa52eb83cf4c2919599c24a
[wait a long time]
code-golf

Or as a brute force attack, run in parallel like this:
$ for L in `seq 1 20` ; do ./reverse-md5 '!"#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~' $L 92a7c9116fa52eb83cf4c2919599c24a & done
[wait a really long time!]
code-golf

Which, depending on the hardware, may give you an answer faster than going sequentially from '!' to '~~~...'

Remove the spaces around the pipe near md5sum, and get rid of the indentation.

Hassium, 138 Bytes
use Math;func main(){d=["laptop","code-golf"];p="312f91285e048e09bb4aefef23627994";foreach(l in d){if(Math.hash("md5",l)==p)println(l);}}

Expanded: http://HassiumLang.com/Hassium/index.php?code=77bf67650e57549addd25daf7503db06

Perl, 75 + 18 = 93 bytes
This program contains nonprintable characters, so here's a hexdump:
00000000: 245f 3d31 3b73 7c30 2a28 2e29 7c24 263d  $_=1;s|0*(.)|$&=
00000010: 7e79 3d20 2d7e 3d21 2d7e 203d 722e 3178  ~y= -~=!-~ =r.1x
00000020: 2124 317c 6520 7768 696c 6520 6d64 3528  !$1|e while md5(
00000030: 245f 296e 6527 92a7 c911 6fa5 2eb8 3cf4  $_)ne'....o...<.
00000040: c291 9599 c24a 273b 7361 79              .....J';say

This program requires the command line argument -MDigest::MD5=md5 (an 18 byte penalty, 17 for the argument and 1 for the space separating it from the other arguments).
Explanation
Here's the program with whitespace and comments added and the binary string replaced with '…':
$_ = 1;                     # $_ is the string to check; start at '1'
s|0*(.)|                    # replace a string of leading 0s plus 1 character
  $& =~ y= -~=!-~ =r        # by rotating 1 printable ASCII character forward
  . 1 x !$1                 # and appending a 1 if the replaced section ends in 0
|e                          # (the previous two lines are a Perl expression)
    while md5($_) ne '…';   # while it has the wrong md5
say                         # print out the value of $_ we found

The basic trick here is that although we want to check from shortest to longest, there's no particular reason to check the characters in ASCIIbetical order. As a result, we check in the order from 1 to ~ then   to 0. To do this, we repeatedly increment the first character after the leading 0s, and reset the leading 0s back to leading 1s (which we can do by incrementing every character up to and including the character after the leading 0s). If the string consists entirely of 0s, we need to append a new 1 to the end; we do this via checking to see if the string consists entirely of 0s via seeing if the last matched character in the regex is 0 (as the 0* match is greedy, this will only happen if there are no non-0 characters in the string).
The reason 1 and 0 are picked as the first and last character in the range is that a) they don't need quoting (the string "1" can be written as 1 because Perl doesn't really distinguish between strings and integers), and b) that Perl has a very short way (!) of checking a single-character string for equality with 0 (Perl has three falsey values: undef, "", and "0", with all other values being truthy).
Note that we have no reason to translate the MD5 hash in question into hexadecimal; it's specified in the question, and so we can pack it into binary ourselves and just compare the binary representations directly. Perl's builtin for producing an md5 hash in binary has a shorter name than the hexadecimal equivalent, and the binary representation takes up half the space in the source, so this is a win in two different ways.
Verification
I tested the program with the hash of the string abc inserted into the source code rather than the hash of the string code-golf, and it found the correct answer in 1.3 seconds. (It's unlikely to be able to reverse the hash of code-golf in a reasonable length of time, due to the need to check a substantial subset of the printable ASCII range.)

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


text:
Concatenate Strings with Context
Strings with Context
For the purposes of this challenge, a string with context is a triple of strings, called the left context, the data part, and the right context. It represents a substring of a longer string. We use the vertical pipe | as a separator, so an example of a string with context is cod|e-go|lf, where the left context is cod, the data is e-go, and the right context is lf. This example represents the substring e-go of code-golf.
Now, to concatenate two strings with context, we proceed as follows, using aa|bcc|dee and cc|de|eee as examples. We align the strings as in the diagram
a a|b c c|d e e
      c c|d e|e e e

so that their data parts are adjacent. The data part of the concatenation is the concatenation of the data parts, in this case bccde. The left context is the part that extends the furthers to the left of the first data part, in this case aa. Similarly, the right context is eee, so the concatenation is the string with context aa|bccde|eee. For a second example, consider a|bb|cd and aabb|cd|, where the second word has a empty right context. The alignment diagram is
  a|b b|c d
a a b b|c d|

where the left context of the second word extends further than that of the first. The concatenation is aa|bbcd|.
But wait, there's a gotcha: if the letters of the alignment diagram don't match, the concatenation doesn't exist! As an example, the diagram of aa|bb|cc and c|c|c is
a a|b b|c c
      c|c|c

where the b and c on the fourth column disagree, so they cannot be concatenated.
The Task
Your job is to write a program that takes in two strings with context whose parts are separated by | as above, and outputs their concatenation if it exists, and something else if not. The "something else" can be any value, including no output, as long as it's not a valid string with context, and it is the same in all cases. However, throwing an error is not acceptable. You can give either a STDIN-to-STDOUT program or a function, and anonymous functions are accepted as well. The smallest byte count wins, and standard loopholes are disallowed.
Test Cases
aa|bcc|dee cc|de|eee -> aa|bccde|eee
a|bb|cd    aabb|cd|  -> aa|bbcd|
a|b|cccd   aab|cc|c  -> aa|bcc|cd
a|b|c      b||cd     -> a|b|cd
aa|bb|cc   c|c|c     -> None
aaa|b|c    abb|cd|d  -> None
|bb|cd     abb|c|ed  -> None
a|b|c      a||cd     -> None

Haskell, 184 182 201 199 155
s&t|(a,'|':b)<-f t,(x,'|':y)<-f$r s,x#b,a#y=r(y!r a)++b!r x|0<1=""
r=reverse
a!b=a++drop(length a-1)b
(#)a=and.zipWith(==)(r a).filter h
f=span h
h=(/='|')

example run:
"|a|"&"|b|" -- returns "|ab|"
"|a|x"&"|b|" -- returns ""

if there isn't a match an empty string will be returned. otherwise the result would be returned.
partial explanation:
# is a function which gets two strings, and returns whether or not they match.
! gets two strings and returns the first one concatenated with extra character from the second (if there are any).
the main function & uses span (/='|') to split the inputs into two parts, a|b|c to a, b|c, checks if the contexts match, and then uses ! twice to assemble the output.
Edit: mage-late regolfing seems to be pretty effective.

Hmm, I'm afraid that throwing an error is not an acceptable output method, especially for a function. Adding |1<2="" to the definition of & should solve that. I'm sorry I didn't specify this more explicitly in the specs, I'll edit it in.

@Zgarb Actually, this would not fix it. Is returning a string with too many '|' signs when the strings don't match okay?

Sure, as long as it is the same string for all non-matching inputs.

Python (242 bytes)
import itertools as i
s='|'
j=''.join
r=reversed
m=lambda a,b:j(j(*set(p+q))for p,q in i.izip_longest(a,b,fillvalue=''))
def c(A,B):
 u,v,w,x,y,z=(A+s+B).split(s)
 try:return j(r(m(r(u+v),r(x))))[:-len(v)]+s+v+y+s+m(w,y+z)[len(y):]
 except:0

Explanation
The lambda function m returns the longer of two strings as long as they share a common prefix. It does this by concatenating the empty string '' in place of any missing values, then turning the result (which may take the forms aa, ab, a, or b in cases of match/mismatch/unequal lengths) into a set of unique characters at each position. join expects a single argument, so unpacking a set with more than one element will cause it to raise a TypeError.
The main function then

uses m to combine the left context and data part the first word with the left context of the second (from right to left over reversed strings)
concatenates data parts,
and again uses m to combine the right context of the first word with the data part and right context of the second

The two original words' data parts are trimmed from the right and left sides of the new contexts.
Since we know that misalignments cause m to raise a TypeError, in these cases we catch the exception and implicitly return None.
Testing
TESTCASES = [
    ('aa|bcc|dee', 'cc|de|eee', 'aa|bccde|eee'),
    ('a|bb|cd', 'aabb|cd|', 'aa|bbcd|'),
    ('a|b|cccd', 'aab|cc|c', 'aa|bcc|cd'),
    ('a|b|c', 'b||cd', 'a|b|cd'),
    ('aa|bb|cc', 'c|c|c', None),
    ('aaa|b|c', 'abb|cd|d', None),
    ('|bb|cd', 'abb|c|ed', None),
    ('a|b|c', 'a||cd', None),
]

for A, B, R in TESTCASES:
    print '{:<10} {:<9} -> {}'.format(A, B, c(A, B))

Output
aa|bcc|dee cc|de|eee -> aa|bccde|eee
a|bb|cd    aabb|cd|  -> aa|bbcd|
a|b|cccd   aab|cc|c  -> aa|bcc|cd
a|b|c      b||cd     -> a|b|cd
aa|bb|cc   c|c|c     -> None
aaa|b|c    abb|cd|d  -> None
|bb|cd     abb|c|ed  -> None
a|b|c      a||cd     -> None


text:
Build a rot32 encryptor
Building a golfed rot13 encryptor is too easy because the letters are all the same order in the ASCII character space. Let's try a rot32 engine instead.
Your task is to build a function that takes a Base64 string as input and returns the same string but with each letter rotated 32 symbols from its original (in essence, with the first bit flipped).
The base64 encoding string to use for this problem is 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/ with a padding character of =. This is to prevent solutions that would otherwise use or import a built-in Base64 library where strings normally start with A instead of 0.
Example inputs and outputs:

> rot32("THE+QUICK+BROWN+FOX+JUMPS+OVER+THE+LAZY+DOG=")
nb8ukoc6eu5liqhu9irudogjmuip8lunb8uf4tsu7ia=

> rot32("NB8UKOC6EU5LIQHU9IRUDOGJMUIP8LUNB8UF4TSU7IA=")
h5Eoei6C8oBfckboFclo7iadgocjEfoh5Eo9AnmoDc4=

> rot32("Daisy++daisy++give+me+your+answer+true/I+/+m+half+crazy++all+for+the+love+of+you")
7GOY2uuJGOY2uuMO/KuSKu2U+XuGTY0KXuZX+KvcuvuSuNGRLuIXG32uuGRRuLUXuZNKuRU/KuULu2U+

The shortest program to do so in any language wins.

From the question, I would understand that we have to do a base-64 decode, some bit-twiddling, and a base-64 encode. But your sample answer suggests that all of the talk about base-64 is a red herring, and it's just like rot-13 except that the set of characters which don't get ignored is larger. Which is it?

It's just like rot-13, but I was thinking bit-twiddling might be a possible strategy to make the code shorter.

CJam, 24 bytes
q"+"":/{a[A"{,^}/_32m>er

Try it online.
How it works
q         " Read from STDIN.                                                              ";
"+"       " Push that string.                                                             ";
":/{a[A"  " Push that string.                                                             ";
{         " For each character in the second string:                                      ";
  ,       "   Push the string of all charcters with a lower ASCII code.                   ";
  ^       "   Take the symmetric difference of the two topmost strings on the stack.      ";
}/        " Result: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789'.   ";
_32m>     " Rotate a copy 32 characters to the right.                                     ";
er        " Perform character transliteration.                                            ";

Bash / Unix shell, 29
tr 0-9a-zA-Z+/ w-zA-Z+/0-9a-v

Input from STDIN, output on STDOUT.

Perl, 41
Just a simple transliteration. Reads from STDIN, outputs to STDOUT:
$_=<>;y#0-9a-zA-Z+/#w-zA-Z+/0-9a-v#;print

Try it out here.

Who says Perl is not an esolang (and/or golfing oriented language)?

You could shave off a few characters by using the -p and -e command line switches to get rid of the $_=<>; and the ;print.

CJam, 45 41 38 29 27 26 bytes
qA,'{,97>_eu"+/"+++_32m>er

Reads the string to be encrypted from STDIN
How it works:
q                              "Read input";
 A,                            "Get 0 - 9 array";
   '{,                         "Get array/string of ASCII code 0 till ASCII code of z";
      97>                      "Remove first 96 characters to get a-z string";
         _eu                   "Copy a-z array and turn it to uppercase A-Z array";
            "+/"+++            "Push string +/ and concat all 4 arrays";
                   _32m>       "Copy the array and move first 32 characters to end";
                        er     "Transliterate input using the two arrays, leaving ="
                               "intact as it does not appear in the first array";

Try it online here

Python, 178
b = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/"

def rot32(s):
    o = ""
    for c in s:
        if c not in b:
            o += c
        else:
            o += b[b.find(c) ^ 32]
    return o

This is an ungolfed, last-place reference implementation in Python that you can use to test your own implementation.

At least, I hope it stays last-place.

GolfScript (41 40 bytes)
{'0:a{A['2/{{,>}*}%'+/'+[1$]+.32/(*@?=}%

Online demo
There are two parts to this: the translation is a variant on the last technique mentioned in my tip on tr in GolfScript, and the other part is the string building, which uses the string 0:a{A[ as an array of char values and a fold to turn them into character ranges. Note the use of 32/(* to build the translated string by inserting the first 32 chars between the second 32 chars and the character we're translating.

python, 69
f = lambda s,b: ''.join(b[b.index(c)^32] if c in b else c for c in s)

tests
>>> b = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/"
>>> print f("THE+QUICK+BROWN+FOX+JUMPS+OVER+THE+LAZY+DOG=", b)
nb8ukoc6eu5liqhu9irudogjmuip8lunb8uf4tsu7ia=

>>> print f('nb8ukoc6eu5liqhu9irudogjmuip8lunb8uf4tsu7ia=', b)
THE+QUICK+BROWN+FOX+JUMPS+OVER+THE+LAZY+DOG=

LiveScript, 91
r=[\0 to\9].concat [\a to\z] [\A to\Z] [\+ \/];f=(.replace /[^\W_]/ ->r[32.^.r.indexOf it])

LiveScript, 50
If the string is allowed as a second argument.
f=(a,b)->a.replace /[^\W_]/ ->r[32.^.b.indexOf it]

JavaScript 164
b="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/"
function rot32(s){for(i=0,o="";i<s.length;i++)c=s[i],j=b.indexOf(c),o+=j>-1?b[j^32]:c
return o}

authors: محمد السميران


text:
Shortest Minmod Function
The minmod function is a variant of the familiar min, which appears in slope-limiting high-resolution schemes for partial differential equations. Given a number of slopes, it picks out the flattest slope, while taking care of relative signs between the slopes.
The function takes an arbitrary number of parameters. Then minmod(x1, x2, ..., xn) is defined as:

min(x1, x2, ..., xn), if all xi are strictly positive
max(x1, x2, ..., xn), if all xi are strictly negative
0, otherwise.

We'll only consider integer inputs, because that does not really affect the implementation and should be more inclusive for some (esoteric) languages.
Write a program or function, which takes n signed integers (for n > 0) via STDIN, ARGV or function argument (you can use an array if that's more convenient than a variadic function), and returns or prints (to STDOUT) the result of minmod(a,b).
You must not use built-in min or max functions (and obviously, no built-in minmod either, if you can actually find that). In addition, you must not use any built-in sorting functions, except to sort a fixed small number of items (less than 5).
If your language doesn't have signed types, you may use an unsigned type and interpret it as two's complement. E.g. if your language only uses unsigned bytes, you can use 255 to stand in for -1 and 128 to stand in for -128, etc.
This is code golf, so the shortest answer (in bytes) wins.
Test Cases
Input          Output

2              2
-3             -3
0              0
3 -5           0
2 4 1          1
0 1 2          0
-1 1 2         0
-4 -2 -3 -2    -2
-5 0 -1        0
1 0 -1         0

Leaderboards
The following Stack Snippet generates both a regular leaderboard and an overview of winners by language. So even if your language of choice doesn't let you win the entire challenge, why not try to snatch a spot on the second list?
To make sure that your answer shows up, please start your 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

function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){$.ajax({url:answersUrl(page++),method:"get",dataType:"jsonp",crossDomain:true,success:function(e){answers.push.apply(answers,e.items);if(e.has_more)getAnswers();else process()}})}function shouldHaveHeading(e){var t=false;var n=e.body_markdown.split("\n");try{t|=/^#/.test(e.body_markdown);t|=["-","="].indexOf(n[1][0])>-1;t&=LANGUAGE_REG.test(e.body_markdown)}catch(r){}return t}function shouldHaveScore(e){var t=false;try{t|=SIZE_REG.test(e.body_markdown.split("\n")[0])}catch(n){}return t}function getAuthorName(e){return e.owner.display_name}function process(){answers=answers.filter(shouldHaveScore).filter(shouldHaveHeading);answers.sort(function(e,t){var n=+(e.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0],r=+(t.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0];return n-r});var e={};var t=1;answers.forEach(function(n){var r=n.body_markdown.split("\n")[0];var i=$("#answer-template").html();var s=r.match(NUMBER_REG)[0];var o=(r.match(SIZE_REG)||[0])[0];var u=r.match(LANGUAGE_REG)[1];var a=getAuthorName(n);i=i.replace("{{PLACE}}",t++ +".").replace("{{NAME}}",a).replace("{{LANGUAGE}}",u).replace("{{SIZE}}",o).replace("{{LINK}}",n.share_link);i=$(i);$("#answers").append(i);e[u]=e[u]||{lang:u,user:a,size:o,link:n.share_link}});var n=[];for(var r in e)if(e.hasOwnProperty(r))n.push(e[r]);n.sort(function(e,t){if(e.lang>t.lang)return 1;if(e.lang<t.lang)return-1;return 0});for(var i=0;i<n.length;++i){var s=$("#language-template").html();var r=n[i];s=s.replace("{{LANGUAGE}}",r.lang).replace("{{NAME}}",r.user).replace("{{SIZE}}",r.size).replace("{{LINK}}",r.link);s=$(s);$("#languages").append(s)}}var QUESTION_ID=42079;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var answers=[],page=1;getAnswers();var SIZE_REG=/\d+(?=[^\d&]*(?:<(?:s>[^&]*<\/s>|[^&]+>)[^\d&]*)*$)/;var NUMBER_REG=/\d+/;var LANGUAGE_REG=/^#*\s*([^,]+)/
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<link rel=stylesheet type=text/css href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	AuthorLanguageSize

Winners by Language

LanguageUserScore

{{PLACE}}	{{NAME}}{{LANGUAGE}}{{SIZE}}Link

{{LANGUAGE}}{{NAME}}{{SIZE}}Link

Reading the input will not be in O(n) if there isn't a limit.

@user23013 Good point. I removed this altogether, because I only added it to rule out sorting functions in the first place. So instead I'm now simply doing exactly that.

Maybe add a column for how many answers are there in each language

@proudhaskeller Hmm, I like that the two tables currently fit next to each other without having go open the snippet full screen - I think it would be a bit too crammed if I added another column. If your comment gets significantly more upvotes than mine, I'll see what I can do. ;)

Both +1'ed.. ;)

I've now allowed sorting of small fixed arrays (as per popular demand).

as per the chat*

@MartinBüttner I think the allowing sorting at this stage is destructive and changes the whole thinking angle towards the question, rendering all existing (answers added before this rule addition) kind of useless and obsolete.

@Timtech and a couple of answers.

@Optimizer I decided that the previous version of the rules was doing more harm to the creativity of people's answers than I had intended. In addition, I was going to award a bounty to the answer that was leading before the rule change anyway so I don't think any harm in terms of rep is done either. (Yes, I agree that rule changes aren't such a good idea, but I figured it would be worth it in this case.)

@MartinBüttner - I don't see any creativity in the newer answers now. It has all come down to reducing to a pairwise minmod. Creativity was in xnor's answers or Mig's approach on which many other answers are influenced on.

True, xnor's solution was brilliant, and I think the newer answers are a bit cheaty.

@Optimizer, it's not always possible to tell whether a new answer is exactly as creative as an older one which it's similar to or whether it's an unimaginative port.

GolfScript, 10 9 bytes
~{0]$1=}*

Assumes input from stdin in the format [-4 -2 -3 -2]
This uses the built-in sort function $, but every time it's invoked it's on an array of 3 elements, which is permitted.
Online demo

Cool, our answers are less than 1 second apart, which means my answer used to be the shortest. ;)

+1, this is way shorter and smarter than my solution. (Ps. In case anyone doubts it, yes, this solution is correct, and it's fairly easy to prove by induction. What Peter's code does is repeatedly compute the median of the previous minmod value, the next input value and zero; an examination of the possible cases shows that this indeed yields the new minmod value.)

What the...well, there is always LOTS of stuff to lean :O

Mathematica, 19 bytes
Median[#~Riffle~0]&

Code and golfing thanks to Martin Büttner.
This is an unnamed pure function that takes in a list of integers as input. Invoke it like
Median[#~Riffle~0]&[{-2, -3, -2, -4}]

or similarly saved to variable.
The code first riffles a zero in between every two elements of the input list, which inserts n-1 zeroes among n elements. Then, it takes the median to produce the answer.
This gives min-mod because it handles each case:

All the numbers are positive, in which case the zeroes are below
them and the median is the lowest positive number.
All the numbers are negative, in which case the zeroes are above
them and the median is the least negative number.
There's both a positive and negative number, and so the middle
element is a zero.

If Mathematica implements its median using the linear-time selection algorithm, then this is also O(n).

Haskell, 62 61 39 38 37 bytes
f s=last[x|x<-0:s,and[x*x<=x*y|y<-s]]

using some comparison magic borrowed from @Zgarb's answer* , namely, x*x<=x*y.
x*x<=x*y is true only when x and y have the same sign and y's absolute value is bigger. note that when x is 0 it is always true.
we determine that x is the result iff it is contained in s, and that for all y in s x has the same sign as y and is smaller in absolute value. if no value in s satisfies this definition, then 0 is the result.
f then works by searching s for an element to satisfy this, and uses 0 as a default.
*though he didn't use it for the reasons I'm using it, and he actually got rid of it by now

Rare for Haskell to be this golfable (and, ironically, still readable). Love it.

JavaScript (ES6), 39 bytes
a=>a.reduce((p,c)=>p*c>0?p*p>c*c?c:p:0)

Love this. Nice use of ES6.

Marbelous, 210 bytes
@0
00
]]\\&002
/\..//&0@0
00..02
MMMMMM//\\
:M
}0}1}0}1}0}1}0}2..}2
^7^7||||&0&1&4<3&0=2{>
EqalLteq{0{<{<<2&1--
&2..&3..}100..&2\/{>
>0&6=0&4&5&6..\/
&3..&5\/{<{0
\/..\/
:|
}000}0
&0Subt
{0&1
}0{0
^7
=0&1
&0
\/

There are three boards used here.
The | board (Ab in the readable version) takes the absolute value of a marble (by either returning the passed marble or zero minus the passed marble, as all arithmetic in Marbelous is unsigned).
The M board (Minabs in the readable version) finds and outputs to the left either the first or second marble passed (whichever has a smaller absolute value), and exiting if a different signed marble is passed.
The M board also releases the marble it holds downward instead of leftward once the last character from STDIN is fetched.
The M board is used in the main board to store the minmod of all checked values at any given time, as it releases the value to be saved leftward, which is then deflected back in.
Trashbins (\/) were only placed under synchronisers that would otherwise print to STDIN.
Input/Output uses STDIN/STDOUT. Both deal with 8-bit values (if you wanted to pass +0x30 and +0x38, place 08 into STDIN).
Libraries and cylindrical boards are both required. Viewing output as decimal numbers is recommended (note that this displays the unsigned value of the minmod result).
Test it here.
Note: For more human-friendly input/output, add Dp under the last line of the main board (before :M), replace ]] with Rd, and add the following at the bottom:
:Rd
}0}0}0
]]]]]]{>
-O-O-O
-O-O-O
*A
Plus
\\*A
..Plus
..{0
:*A
}0}0
<<<<
<<
<<
Plus
{0

This simply changes the output to be 3 decimal digits. Likewise, input with these changes requires a space separated list of 3 decimal digits per number.
Readable Version:

Python 2, 53
lambda l:reduce(lambda a,b:sorted([a,b,0])[1],l,l[0])

The idea is to use reduce to turn the two-input min-mod finder into an n-input one. I came up with it independently of the other answers that use it. Only Python 2 supports reduce.
The two-input solution simply finds the median of the two numbers and zero. See my Mathematica answer for a more direct way to use the median.
Less golfed:
def f(l):
 A=l[0]
 for x in l:A=sorted([a,b,0])[1]
 return A

A hypothetical amalgam of Python 2 and Python 3 would be a character shorter, with the starred assignment from Python 3 and input() and print from Python 2.
#Not real code!
A,*l=input()
for x in l:A=sorted([A,x,0])[1]
print A

Old code, without sorting:
lambda l:reduce(lambda a,b:[a,b][a*a>b*b]*(a*b>0),l,l[0])

Hm, yes, I noticed that side-effect in the meantime, but I feel like it's too late to fix it now. Mathematica has a built-in Median though.

Your latter approach is now valid, too.

TIS-100, 696 526 bytes
@1
MOV UP ACC
SAV
ADD 999
JEZ A
SWP
MOV 1 ANY
MOV ACC ANY
JRO -7
A:MOV 12 ANY
@5
S:JRO UP
MOV UP ACC
JLZ A
JEZ B
MOV 1 DOWN
JMP B
A:MOV 7 DOWN
NEG
B:MOV 1 RIGHT
MOV ACC RIGHT
MOV ACC RIGHT
JMP S
MOV 14 DOWN
MOV 9 RIGHT
@6
MOV 999 ACC
L:JRO LEFT
SAV
SUB ANY
JGZ A
MOV ANY NIL
SWP
JMP L
A:MOV ANY ACC
JMP L
MOV ACC ANY
@9
S:JRO UP
JEZ A
SUB 1
JEZ A
JMP X
A:MOV 1 ACC
JMP S
JEZ B
SUB 2
JEZ B
X:MOV 6 ACC
JMP S
B:MOV 2 ACC
JMP S
MOV ACC ANY
@10
MOV LEFT ACC
ADD 1
JRO ACC
JRO 6
MOV UP ANY
MOV UP ACC
NEG
MOV ACC ANY
!NOP
MOV 0 ANY

Expects the sequence to be terminated by -999. TIS-100 is newer than this question, but it's not like that matters here anyway.
Node 9 keeps track of whether we're all positive, all negative or mixed. Nodes 5 and 6 work to find the minimum of the absolute value of all input numbers. Node 10 then selects the minimum, the minimum negated, or 0 depending on node 9's state.

I have implemented a TIS emulator for TIO, so you can now try it online!

Haskell, 83 40 39 bytes
This is probably not the shortest possible Haskell solution (and certainly won't beat the others here), but it's a start. EDIT: Now over 50 % shorter! EDIT2: One byte less...
a#b|a*b<0=0|a*a<b*b=a|1<2=b
m=foldr1(#)

This is just a straightforward fold (or reduce, as some languages call it) by the binary operator #, which computes the median of a, b and 0. Even though the rules would now allow me to sort small lists, this requires an import in Haskell and results in a higher byte count (49 bytes, but 31 without the import):
import Data.List
a#b=sort[a,b,0]!!1
m=foldr1(#)

\a-> (signum a,a) is the same as signum>>=(,) using the function monad instance. (see my post in "tips for golfing in haskell")

Thanks for the tip, but it's now moot. :)

@Zgarb Ah okay.

CJam, 20 bytes (or 10 bytes)
q~{]__~z\z<=\~*0>*}*

Using @xnor's approach, reduce calculating minmod of 2 numbers at a time from the array.
This would have been 19 bytes if :z worked

Using the new rule of using sorts on short arrays:
q~{0]$1=}*

which is exactly equivalent to @Peter's answer

Previous 26 bytes asnwer:
q~_{g}%_|:+\(z\{za+_~>=}/*

This can be golfed further...
Input (via STDIN) is the integer array like :
[-4 -2 -3 -2]

and output is the minmod of the input array
Try it here
If only :g and :z worked, this would have been 4 bytes shorter.

25 bytes: q~_{g}%_|:+\{z\za+_~>=}**.

Fails for single int array. I tried it too :)

Although there is a 26 byte solution in there . Thanks for that :)

TI-BASIC, 19 bytes
Assumes input in the format {-2,4,3}.
Works similarly to xnor's answer:
Input L₁              get user input into the L1 array
dim(L₁)2-1→dim(L₁     get the length of the array; multiply by 2 and subtract 1
                      make this the new length (new elements always default to 0)
median(L₁             calculate and return (since it's the last line) median of new array

Interesting way of counting code size...

@Ypnypn turns out, we're fine with it, though

My code, as well as median(augment(Ans,0ΔList(Ans at only eight bytes, fails on lists of dimension one.  If variance(Ans:augment(Ans,0ΔList(Ans:median(Ans is longer than yours. If only TI-BASIC supported empty lists...

You are right. It looks like that bumps my code size from 12 to 15 bytes.

I guess you're right. +4 bytes there.

Java, 84 bytes
This is Java in all its glory. Beats GolfScript by a factor of slightly over 900%.
int f(int[]a){int b=a[0],c;for(int d:a)b=(c=d<0?-1:1)*b<0?0:d*c<b*c?d:b;return b;}

Wrapped in class:
public class MinModGolfed{

    public static void main(String[] args){
        int[] numbers = new int[args.length];
        for (int i = 0; i < args.length; i++){
            numbers[i] = Integer.parseInt(args[i]);
        }
        System.out.println(new MinModGolfed().f(numbers));
    }

    int f(int[]a){int b=a[0],c;for(int d:a)b=(c=d<0?-1:1)*b<0?0:d*c<b*c?d:b;return b;}

}

Expanded with comments:
public class MinModExpandedGolfed{

    public static void main(String[] args){
        int[] numbers = new int[args.length];
        for (int i = 0; i < args.length; i++){
            numbers[i] = Integer.parseInt(args[i]);
        }
        System.out.println(new MinModExpandedGolfed().f(numbers));
    }

    int f(int[]a){                  //a is the input numbers
        int b=a[0],c;             //b is the best number found so far.
        for(int d:a)               //Iterate over a with current element as d.
            b=(c=d<0?-1:1)         //c is equal to the sign of d.
                    *b<0?
                        0:          //If b has opposite sign of d, b = 0.
                        d*c<b*c?d:b;//If the absolute value of d is less than b, b = d.
        return b;
    }

}

Note: This can be improved using Java 8.
Note: Effort to improve in Java 8 failed.

I have much to learn yet. +1.

J, 20 12 bytes
Function taking the list as argument. Stolen from the Golfscript/CJam/whatever.
(1{0/:~@,,)/

The minmod of x and y is the median (sort /:~ and take the middle 1{) of the three item list 0,x,y. Reduce the list (folding in J parlance) by taking this minmod between adjacent elements.
In use at the REPL. (J spells its negative sign _.)
   (1{0/:~@,,)/ _4 _2 _3 _2
_2
   f =: (1{0/:~@,,)/    NB. give it a name
   f 1 1 2
1
   f 0 1 2
0
   f _1 1 2
0

Old garbage, before I noticed short sorts are allowed: 0:`<.`>.@.(*@]*0<*))/ The minmod of x and y is 0 (0:) if 0 is greater than or equal to the product of x and y, else it is the min (<.) or the max (>.) between x and y depending on the sign. Fold this over the whole list.

Python 2, 82 79 71 69 61 bytes
lambda l:reduce(lambda G,H:[H,G][(G>H)^(G>0)]*(G*H>0),l,l[0])

This is based off of my pyth answer, which was inspired by Mig's answer.

Old answer:
l=input()
m=l[0]
k=1-2*(m<0)
for i in l:m=[m,i][m>i*k]
print(k*m>0)*m

This is a very long answer. I feel like having 2 variables is a waste...? I was right...? ish? ;p

Pyth, 25 22 20 12
uhtS[0GH)QhQ

Probably not novel, but original :P

Pre-sorting allowed
u*?Gx>GH>G0H>*GHZQhQ

Pyth
Try it online.
The idea to use reduce and ternary statements was shamelessly stolen from Mig's answer, but I have no idea if these algorithms are otherwise even similar, as I can't read ternary statements.
Explanation:
Q=eval(input)         : implicit
u                QhQ  : print reduce(lambda G,H: ..., Q, Q[0])
 *          >*GHZ     : ... * (G*H>0)
  ?G       H          : G if ... else H
    x>GH>G0           : G>H xor G>0

No need of tQ. Q will also work

Quite right! I also think I can remove one of the ? for a *...

KDB/Q, 43 characters for function body definition
Thanks to great ideas from previous posts:
f:{$[all 1_0<(*':)x;{$[<[x*x;y*y];x;y]}/[x];0]}

Enter single number using enlist
f[enlist 2]
f[enlist 0]
f[enlist -2]
f[2 4 1]
f[0 1 2]
f[1 0 2]
f[-1 1 2]
f[-4 -2 -3 -2]
f[-5 0 -1]
f[-5 -0 -1]
f[1 0 -1]

I'm sure some Q guru can come up with shorter ones.

Perhaps something like {asc[0,x,y]1}/?

C#, 101 bytes
My first try at code golfing and in a pretty golfing hostile language. Based on reduce (Aggregate in LINQ) and very similar to the JavaScript answer by Mig. Can be run like (new System.Linq.M()).m(new[] {1, 2, 3}). Passes all test cases, but doesn't handle empty input arrays.
namespace System.Linq{class M{public int m(int[]i){return i.Aggregate((a,b)=>a*b>0?a*a&|{,)/

The function reduces the list (called folding (/) in J) with the expression:
(signum(x) == signum(y)) * [x,y][abs(x)>abs(y)] where
[x,y][abs(x)>abs(y)] is y if abs(x) > abs(y) else x.
Example:
   (=&**>&|{,)/ 5 2 6
2

Try it online here.

Java, 353 304 124 bytes
Put together the worst language for code golf with the world's worst golfer and you get...

int m(int[]a){int m=a[0];if(m<0)for(int i:a){m=(i>m)?i:m;m=(i>0)?0:m;}else for(int i:a){m=(i<m)?i:m;m=(i<0)?0:m;}return m;}}

Ungolf it and you get:
int m(int[] a) {
    int m = a[0];
    if (m < 0) {
        for (int i : a) {
            m = (i > m) ? i : m;
            m = (i > 0) ? 0 : m;
        }
    } else {
        for (int i : a) {
            m = (i < m) ? i : m;
            m = (i < 0) ? 0 : m;
        }
    }
    return m;
}

This is a function (if it wasn't pretty damn obvious) that receives an array of numbers and processes its values, returning the minmod value.
My old benemoth of a sollution is also included, which is a whole program - as always.
class M{public static void main(String[]a){java.util.Scanner s=new java.util.Scanner(System.in);int n,m=0;try{m=s.nextInt();if(m<0)while(true){n=s.nextInt();m=(n>m)?n:m;m=(n>0)?0:m;}else while(true){n=s.nextInt();m=(n<m)?n:m;m=(n<0)?0:m;}}catch(java.util.InputMismatchException e){System.out.print(m);}}}

Ungolf it and you get:
class M {

    public static void main(String[] a) {
        java.util.Scanner s = new java.util.Scanner(System.in);
        int n = 0, m = 0;
        try {
            m = s.nextInt();
            if (m < 0) {
                do {
                    n = s.nextInt();
                    m = (n > m) ? n : m;
                    m = (n > 0) ? 0 : m;
                } while (true);
            } else {
                do {
                    n = s.nextInt();
                    m = (n < m) ? n : m;
                    m = (n < 0) ? 0 : m;
                } while (true);
            }
        } catch (java.util.InputMismatchException e) {
            System.out.print(m);
        }
    }
}

Receives infinite numbers, stops when a non-number value is entered, presenting the Minmon value.

Your code seems to discard the first value, so it will give incorrect answers for e.g. 1 2 3. You also seem to be overlooking that you can write a function which processes its arguments rather than a program which reads from stdin.

@PeterTaylor Foolishly, my first instinct is always to write a full program even if it's stated that it can be a function. About that bug, apparently I didn't tested it enough, rats. Will try to correct it now - and make a function-only version as well...

Game Maker Language, 489 bytes
About Game Maker Language
Riffles the array (zeros are appended) and returns the median (similar to my other answer)
i=0a=argument0
while(variable_local_array_get(a,i))i++
for(j=0;j++;j<i-1)a[j+i]=0var i,j,d,m=0d=ds_list_create()if variable_local_exists(a){if variable_local_array_get(a,0){for(i=0;i<32000;i++){if variable_local_array_get(a,i)=0break
ds_list_add(d,variable_local_array_get(a,i))}ds_list_sort(d,0)i=ds_list_find_value(d,ds_list_size(d) div 2)j=ds_list_find_value(d,(ds_list_size(d) div 2)-1)m=ds_list_find_value(ds,ds_list_size(d) mod 2)ds_list_destroy(d)}if m return (i+j)/2return i
break}

@MartinBüttner The first 2.5 lines perform the riffle, and the rest finds the median. The 32000 is the maximum size of the array as limited by the software.

@MartinBüttner Yes, within the median part, the whole list is not sorted.

@MartinBüttner it is sorted every iteration... so 3

Ohhh, I see. That code is surprisingly hard to read for such a wordy language. ^^

@MartinBüttner It's pretty good for golfing (very loose syntax) but it does not contain many standard built-in functions (it is oriented towards game design).

R, 20 chars
R is usually not good for codegolf, but I use it for my work so I wanted to try. Before I tried, I didn't know that R is willing to accept such a dirty syntax! :-) 52 chars:
if((q=summary(x))[6]<0)q[6]else if(q[1]>0)q[1]else 0

Then I looked the other answers I tried @xnor's genial median trick, which is great!
median(c(x-x,x)[-1])

How does your first version work? What does summary do? Are q[1] and q[6] min and max, respectively? In that case, that's not valid, because you can't use built-in min/max.

@MartinBüttner it basicly provides a vector of quantiles and a mean. 1 and 6 are 0 and 1 quantiles. I have not used built-in min/max function, as per your rules.

Python, 52
I still couldn't help feeling that it's bad to have two lambdas. This function takes in a list and then returns a one-element list containing the result.
f=lambda a:a[1:]and[sorted([a.pop(),0]+f(a))[1]]or a

Hopefully, it will not cause an enormous amount of offense to have the result in a one-element list.

Matlab/Octave, 26
This is basically just a translation of the Mathematica answer by xnor.
It works by appending one zeros less than the length of the input vector. Note that appending one more would not work, since then the result would be 0 all the time. Thanks to MartinBüttner for the -4 chars of this solution=)
@(x)median([x,0*x(2:end)])

@MartinBüttner You are absolutely right. I now altered it: The program will only append one zero less than the input. This way it is ensured that we have always an odd number of elements and the median takes care fo the rest.

or pop the last 0 from your previous solution.

@MartinBüttner Thanks, of course thats way better. @ Optimizer How would you do that?

I have no idea. I thought there must be a way to simply pop off the last element, something like @(x)median([0*x,x](2:end)) . Although it seems like that its the same bytes as now.

@Optimizer I already thought I missed an important feature of Matlab=) It is too bad that the notation you suggested does not work, it would be really handy sometimes!

Python, 72 60 bytes
This is the first solution I thought of, and it's quite naive. The second half is basically a duplicate of the first half of the code, but I wasn't sure how to slim it. I wonder if it can be shortened using eval...
Edit: Changed lambdas to comprehensions.
Try them here
lambda l:min(l)*all(x>0for x in l)+max(l)*all(x<0for x in l)

This is only 4 chars longer, but still worth looking at, using Sp3000's TIP.
lambda l:eval("+m%s%s(l)*all(x%s0for x in l)"*2%tuple("ax<in>"))

Javascript, 63
a=>a.reduce((p,c)=>p<0?c<0?Math.max(p,c):0:c>0?Math.min(p,c):0)

A more readable version:
function (arr) {
    return arr.reduce(function (p, c) {
        if (p < 0) {
            if (c < 0) {
                return Math.max(p, c);
            } else {
                return 0;
            }
        } else {
            if (c > 0) {
                return Math.min(p, c);
            } else {
                return 0;
            }
        }
    });
}

authors: حميد التلتوب

authors: ณรงค์กร ชูวงษ์วาน