text:
All Your Base Are Belong To Us (Restricted)
Input must not be required, and output must read "All your base are belong to us".
Restrictions

No external resources.
Plus a minimum of two of the following:

You cannot use "a", "b", "t", "u", or "y" in any case in your code (bonus -10 to your golf score if you can do this)

You cannot use "l", "o", "s", "e", or "r" in any case in your code (bonus -20 to your golf score if you can do this)

You cannot use "n", "g", "0", "1", or "2" in any case in your code (bonus -30 to your golf score if you can do this)

So for example, if you manage to get the code done with 40 characters and use rules 1 and 2, your golf score is 40 - 10 - 20 = 10 chars.
Smallest code golf score wins... Good luck!

So much as declaring a string breaks all three restrictions, and char, var and Write break two of them each.  This is going to be tough to get valid answers, bar maybe Barinfuck.

Very difficult in python. print breaks all three. Maybe with some creative eval, but then you have to meet 1 and 3.

Ok, I'm convinced a Python entry is impossible.

"no input required". Doesn't that mean that I could, for example, do something like print(input()) (python)? The user would be required to input the correct string, but that isn't forbidden.

I'm pretty sure a Python entry is possible with exec and clever use of hex escapes.

As far as I can figure out an entry in C would only be able to output with putc since it only violates one of the rules, all other output functions I can imagine right now violate two of the rules. But. putc will have to have stderr or stdout as the second argument violating two rules anyway. Correct me if I missed some way to output or acquire stdout (write, printf, putchar, send (if it worked at all which it probably doesn't), fdopen).

@user2357112 hard to avoid 0, 1, and 2 with hex escapes, and exec contains the e already.

@Art I don't have a computer nearby atm, but I believe stdin/out/err have values 0, 1, 2 respectively, so you can simply hardcode them.

@Art C is out anyway since you need main.

@quasimodo Doh. Of course, that's even more obvious. No point to research esoteric I/O functions when the entry point itself is impossible to write.

Looks like POGAACK is out of the question...

@gerrit: You can get them into a hex escape with backticks around arithmetic. It just requires another layer of exec.

@user2357112 backticks are an unconditional SyntaxError in Python3.  They're deprecated (but valid) in Python2.

I think any input used should be subject to the same rules, and count as characters in the score.  It doesn't look like some answers are doing that.

@Quincunx I wouldn't accept such a solution, as the code is not guaranteed to output a correct solution. Also, stdin is arguably an "external source".

@PranavHosangadi There is a deleted answer to this question with a score of -6 which is essentially the same as that. It's been done before a number of times in various questions and is explicitly disallowed in the [tag:code-golf] tag.

According to code-golf standard rules answers in latin1/unicode/name you charmap is rated in bytes after conversion to utf-8. Are we to count like that or have you chosen a different score method? Current leader would then be at 0 instead of -40.

@PranavHosangadi Technically anyone can "create" a custom language that takes a single command, arbitrarily called z or something, and the result is the desired output... We don't do that sort of thing here...

If I can't use l, o, s, e, and r, can i use w, i, n, n, e, and r? ;)

@Makonede, you could, but you wouldn't be able to apply the -20 and -30 bonuses... ;)

SOGL V0.12, 15 - 60 = -45
šz█P'zUS½█│β3‘⁾

Try it Here!
šz█P'zUS½█│β3‘ is a compressed string of all your base are belong to us, but because that exact string compressed contained 0, it's split into 3 parts: all your base are,  , belong to us (which cost one byte but gave a -30 byte bonus). The first and last strings are compressed with SOGLs English dictionary, and implicitly joined with spaces. The remaining ⁾ is a simple sentence case built-in.
Note that SOGL postdates this challenge, but that's allowed now.

I just have to ask... How??? Are we dealing with some clever compression technique here? I know nothing about SOGL...

GolfScript, -22 (38 characters, -60 bonus)
"„¯¯c¼²¸µc¥¤¶¨c¤µ¨c¥¨¯²±ªc·²c¸¶"{67-}%

How does this work?

ooooooo, shifty

@RyanCarlson Magic.

"..." defines a string and the block {}% performs a mapping operation over all characters. Inside the block the ascii value is available on the stack and 67- subtracts 67 from each ascii value.

Isn't superscript 2 just a different case of 2? In which case, you haven't met rule 3 and your bonus is only -30.

@FizzBuzz Numbers don't have case.

OK, case is probably the wrong word to use, but you know what I mean. I'm pretty sure superscript 2 is still a 2, so Rule 3 hasn't been met.

@FizzBuzz I know what you're trying to say, but I think what matters is that 2 and ² are different glyphs with distinct codepoints. You can make the argument that, in a denotational sense, they are the same symbol, but I think that's a far more abstract interpretation than the question merits.

@FizzBuzz Strike that—I just noticed that someone is being stomped in the comments for Kendall Frey's answer for suggesting that character refers to glyphs/codepoint. Apparently it means whatever interpretation is most convenient for any given answer.

@FizzBuzz superscript 2 doesn't behave like 2 in maths. It is shorthand for the power of two. Much the same way as I would consider & valid in a question which doesn't allow and as far as a computer is concerned these are two different entities. In this case though I think the community has to decide as this is total opinion.

Font doesn't $%@#ing matter.  Does the source contain the byte?  No?  ! off.

@FizzBuzz, I'm siding with @Howard and @JordanGray ² is deemed as a separate character to 2. They have different Unicode signatures, in the same sense that A is not the same as Å or Ã

Sclipting, −40
뀖롬긇땯덗긠눦굳뉒걡댦넠눦녬닶멧긇끯긇녳

= 20 characters − 60 bonus
Only works if the input is empty, which I take to be the case; if not, add 丟 in front, changing the score to −39.
If I can assume the input to be what I want (as this answer apparently does), then the empty program is a solution and my score is −60.

Well, "input is not required" as I said, so I'd throw the 丟 in front and alter the score to -39, but great effort! Especially considering you invented the language, dude!

As a Korean seeing Korean syllables in code is amazing.

Brainfuck, 267 - 60 = 207
++++++++[>++++++++<-]>+.<+++++++[>++++++<-]>+..>>++++++[<+++++>-]<++.<+++++++++
++++.----------.++++++.---.>.<<++++[>----<-]>.-.<+++[>++++++<-]>.--------------
.>.<----.<++++[>++++<-]>+.-------------.>.<---.+++.+++++++.+++.-.-------.>.<+++
++++++++++.-----.>.<++++++.--.

Can that be reduced any further, I wonder? :)

fbonetti did better in his Brainfuck answer.

And FIQ did even better 4 days later

JavaScript - 140 bytes - 60 bonus = 80 points
(x="Ǎľľ y̌ǒǔř b̌ǎšě ǎřě b̌ěľǒňǧ ťǒ ǔš")[x[3*9]+x[34]+"p"+x[4]+x[5*5]+"c"+x[34]]("̌","",x[6*7])

Run in Firefox.
I know what you're thinking. No, those aren't the characters that are listed in the question. Those are characters with a caron, or háček (picked randomly from a list of diacritics). Even though they're combining marks, they aren't two separate characters.

Node.js REPL: String.fromCharCode(65,108,108,32,121,111,117,114,32,98,97,115,101,32,97,114,101,32,98,101,108,111,110,103,32,116,111,32,117,115);

APL (43 - 30 - 20 = -7)
⎕AV['⊥┤┤ ø┼&┐ `∣┘û ∣┐û `û┤┼─ù ´┼ &┘'⍳⍨⌽⎕AV]

This satisfies rules 2 and 3.

This is going to be hard to beat!

does this return the result or print it?

@AaronDavies: both, the result is automatically printed

@marinus I tried this in http://TryAPL.com and got an INVALID TOKEN error.... perhaps from the initial and tailing character before AV... Is there any other place I can test this...?

@WallyWest: use Dyalog APL (http://www.dyalog.com). Get the unregistered version, it's free. TryAPL is so limited it's nearly useless.

HTML/CSS 70

sn oʇ ƃuoləq əɹɐ əsɐq ɹnoʎ llɐ

http://jsbin.com/EjekuvuF/1/
I thought I was being clever with the upside down type but then realized I couldn't meet any of the ancillary rules with the actual HTML/CSS. Oh well.
UPDATE:
User Flame suggested a more cross-browser compliant solution:

sn oʇ ƃuoləq əɹɐ əsɐq ɹnoʎ llɐ

http://jsbin.com/EjekuvuF/6

I guess you can use XML character references to salvage the situation.

I like the idea behind the solution though.

I'll give props to it too... thought for some reason transform:rotate(.5turn) resolves to a Syntax error... I like the imagination put into this...

@WallyWest I didn't test in all browsers. I bet that might be browser-specific rather than the official W3C syntax. (Does work in Chrome, though)

You should use ∀ instead of ɐ :)

MATLAB, All bonuses: Score of -20 (40-60)
['' '¤ÏÏèÜÒØÕèÅÄÖÈèÄÕÈèÅÈÏÒÑÊè×ÒèØÖ'-99]

EDIT:
Note that I am not sure of what the system requirements are to run this, tested on windows. For those struggeling to copy, a similar code can be generated like so:
char('All your base are belong to us' + 99)

If it would have been allowed to ask anything as input, a solution with less characters (but also missing the bonus) would of course be possible.
input('')

Please explain how you plan to output anything using only input. The second answer is (afaik) just not true.

@Jhawins: MATLAB outputs the result of each expression that doesn't end in a semicolon.  The input('') call doesn't end in a semicolon, hence it will generate output.

If that's correct, then my JS answer is "prompt()"

And shell would be dd, but perhaps that counts as an external resource.  So would user input, of course.

I tried running this and got the following:
_A,,E9/52E"!3%E!2%E"%,/.'E4/E5`3
I can understand the first answer, but the second answer requires input, which I said was not "required"

byte count is off. Even though solution is in iso-8859-1 (I guess) teh byte count is after utf-8 conversion. Around 70 without bonuses perhaps?

I don't see why the byte count is relevant, a simple count leads me to this amount of characters as is mentioned in the scoring. It seems that some people have trouble copying the code into matlab, a similar code can easily be generated with: char('All your base are belong to us' + 99)

being pedantic for a moment: Wanted output contains a trailing space. Yours does not.

k (-7 = 53 - 60)
(#`)"c"$(465%3)-6h$"Z//{\",&){9:(6{:)6{96/,-4{',{&(";
doesn't include trailing newline, can be added at cost of one additional char:
(-#`)"c"$(465%3)-6h$"Z//{\",&){9:(6{:)6{96/,-4{',{&(";
annoyingly, the only offsets that work for this trick are 154 and 155
edit:
if it's sufficient to display the string (rather than printing it), as i suspect the APL solution does (it doesn't work in http://tryapl.com/, so i can't test it properly), it's
  "c"$(465%3)-6h$"Z//{\",&){9:(6{:)6{96/,-4{',{&("
"All your base are belong to us"

which is -12 = 48 - 60. can i get a ruling on whether this is sufficient?

I never asked for a trailing newline... :)

Python REPL, 122 116 98 characters - 30 bonus = 92 86 68 points
>>> '\x41\x6c\x6c \x79\x6f\x75\x72 \x62\x61\x73\x65 \x61\x72\x65 \x62\x65\x6c\x6fng \x74\x6f \x75\x73'

'All your base are belong to us'

I could get rid of the zeroes in Python 3.3 by replacing '\40' with \N{SP}, but alas, the N is not permitted.
Edit: Inspired by this answer, I've shortened it further by replacing \x40 by .  Moreover, since I already use the 1, replacing \156 by n and \x67 by g shortens it by another 6 characters while incurring no extra penalty.

I wonder if it's possible to get rid of all the repeated \x with a list comprehension, but that would probably necessitate eval and/or list/generator comprehensions with the keyword for, and/or join...

I wonder if this is this a valid entry, because it only works the interactive shell. If you put this in a .py file and execute it, there is no output.

@DanielHepper I'm new to code golf and this site.  Are there any rules regarding this?

my understanding was that it has to be an executable program, but I might be mistaken

It depends... I believe there is no general rule. Some questions allow interactive mode, others don't.

I've posted the question on meta.

This works in R too

I wrote a function which doesn't write anything to the console, but it can have input and output.

I beat this for Python, with a score of 74! :D http://codegolf.stackexchange.com/questions/19171/all-your-base-are-belong-to-us-restricted/19412#19412

@AaronHall And after my edit, I brought mine down to 68!

Very Smart move! Of course: len("'All your base are belong to us'")
32

Not obfuscating loser instead of ng should be 11 literal chars instead of only to and should save 27 bytes and 10 bonus. Oh ... the ASCII codes contain 1 and 2. Pity.

dc, 97 - 60 = 37 91 - 60 = 31 88 - 60 = 28 81 - 60 = 21
3C87596P4d^8/P7958389P7479394P6386533P7C89P749698CP644848CP459 8^699 7^3849736388974773333 86-++P

Improved version (the main idea here is to vary the input base, to increase the chances of finding a useful big number with no problematic digits):
IDi67793554D647F84C836645D6569F69Pi6385C77P9i35PDdi6^I9^+6D59CD83D664D34+P8CPFi98CCF5PCi97P

In base 7, the whole thing can become a single number! Lower bases are naturally less compact, but the lack of fix-up operations here makes up for it.
7i4398873968644388737548444897643735447698675366869556798538985674336396359936458859886P

My first solution used base 10. My second used a mix of base 9, 10, 12, 13, and 15. This one is in base 7. I truly feel like all the base are belong to me.
Last one, seriously: Base 13 does a great job on the first segment, then base 7 for the rest.
Di67793554D647F84C836645D6569F69P7i798789699638355733695878558396339387963789536P

So in other words, all your base 7 are belong to you, @Wumpus?

Brainfuck, 205 203 - 60 = 145 143 bytes
++++[->++++<]>[->++++>++>+++++++>++++++>++++++++<<<<<]>+.>>----..<.>>>-------.<<+++.>>----.---.<<<.>>++.-.>+.<++++.<<.>>----.>-.<++++.<<.>>---.+++.<---.>>---.-.<<-----.<.>>>++++++.-----.<<<.>>>++++++.--.

Readable version:
++++[->++++<]>[->++++>++>+++++++>++++++>++++++++<<<<<]
64 32 112 96 128

>+.>>----..<.                     All                 65 108 108  32
>>>-------.<<+++.>>----.---.<<<.  your           121 111 117 114  32
>>++.-.>+.<++++.<<.               base            98  97 115 101  32
>>----.>-.<++++.<<.               are                 97 114 101  32
>>---.+++.<---.>>---.-.<<-----.<. belong  98 101 108 111 110 103  32
>>>++++++.-----.<<<.              to                     116 111  32
>>>++++++.--.                     us                     117 115

Good effort!

I kinda half-expected a Brainfuck solution eventually... Nice work!

Befunge 98 : 122 - 60 = 62
5f8+*:53-+:' \6-:5+' 91+:*3+::7+\8+:3-:7-:3-:' \3+::3-4+',' -+\4-:' \:4+\6+c+:f3+-:4+3-' '&3*:3+:6-:f+5-:' \d-:' '!+ff+k,@

Computes the ascii values, then prints them. I still need to try out other methods of forming the numbers to see if there are shorter ways.

I was wondering when you were gonna put your 2 bytes in... Nice work!

Python, 195-40 = 155
x,w,y,z,v=4*8,55,56,57,58;exec(("%c"*38)%(y+y,z+z,49+y,w+w,v+v,39-7,34,65,54+54,54+54,x,v+63,48+63,48+69,z+z,x,98,97,59+y,45+y,x,97,z+z,45+y,x,98,45+y,54+54,w+y,w+w,45+v,x,v+v,w+y,x,v+59,z+v,34))

Ruby, 121 - 50 = 71
A bit brute force, but most of the cute methods are ruled out:
$><<[65,c=36*3,c,d=8*4,363/3,f=c+3,c+9,c+6,d,x=98,97,j=c+7,k=3+x,d,97,c+6,k,d,x,k,c,f,j-5,5+x,d,c+8,f,d,c+9,j].pack('C*')

Breaks rule #1 because of the A in pack, the other two should be OK.

I can save 6 chars if we're just returning the result rather than printing it, I wasn't clear on that after looking at the other answers.

Extremely long, but no more “a”: http://pastebin.com/wnsvcAMh

@manatwork I love it!  Somehow I never thought of that, even though I'm using << in my answer.

So you either use the 154 character solution @manatwork has used and claim the 60 point discount which gives you 94, or stick with the non-Rule 1 version and go with the 71... I know which I'd use :)

{ba,z}sh, 67 - 40  72 - 60 61 - 40 = 21
$'\x74r' K-~\#-\; _@-~\^-j<<<'Mxx ){%~ 3m#q m~q 3qx{z8 ${ %#'

Darn it, turns out I had a r in there that I hadn't noticed, so the 20 bonus doesn't apply!

In the zsh and bash versions I have handy, $'\x74\x72' can be used directly as a command name, saving you 8 characters for the $(m4<<<). Doesn't it work that way for you?

And after looking at it again... using \x72 as a replacement for r gets you the 20 point bonus at the cost of losing the 30 point bonus (for the 2)

@WumpusQ.Wumbley oh, you're right on both accounts. I didn't think of the 2 used there, let me see if I can find a way to get rid of it and avoid losing any bonuses.

Holy sh#t, that was ingenious! This looks like a Reverse ROT12 ASCII cypher... (am I right?) nicely done!

Nice answer.  But does tr count as an external resource?

@DigitalTrauma I don't think so; it's a standard utility spec'd by POSIX.  See tr(1)

@FireFly - If you want to drop the r in tr, you can borrow from my answer http://codegolf.stackexchange.com/a/19421/11259 z=({m..v});$'\x74'${z[5]} K-~\#-\; _@-~\^-j<<<'Mxx ){%~ 3m#q m~q 3qx{z8 ${ %#'.  78 chars - 60 = 18.

Does this print the trailing space?

@Titus it prints 31 characters with a trailing newline included (so, it prints "All your base are belong to us\n" to stdout). No trailing space characters on the line. I think that should be correct?

Sorry there´s a gap between the wanted output and the closing quote; I misread that as a space. I don´t think that you need the newline.

C, 75 bytes - 60 = 15
Thanks to @gastropner for getting the score down from 50 to 33 and from 19 to 15!
*q,i;f(p){(*(q=p)="\v&&j3%?8j(+9/j+8/j(/&%$-j>%j?9J"[i++]^74)?i=!f(++p):i;}

Takes the address of a char array as input and writes the string to the array.
Try it online!
Call with:
int main()
{
    char s[128];
    f(s);
    puts(s);
}

Output:

Old version (90 bytes - 40 = 50):
*q,i,j;f(p){for(i=3-3;j="Epp$}s v$fewi$evi$fipsrk$xs$ w"[i++];*q=j!=35-3?j-4:353/3)q=p++;}

Riffing on this, using the powers of XOR and recursion, you can reach 93 - 60 = 33 bytes: *q,i,j;x(p){if(j="\v&&j3%?8j(+9/j+8/j(/&%$-j>%j?9"[i++])*(q=p)=j^74,x(++p);}f(p){i=3-3;x(p);}

@gastropner Thanks!

Could go with i=i<30 for another 2 bytes off.

@gastropner Can't use 0.

Ah, yes, of course!

75 - 60 = 15 bytes. Still looks to be reusable: *q,i;f(p){(*(q=p)="\v&&j3%?8j(+9/j+8/j(/&%$-j>%j?9J"[i++]^74)?i=!f(++p):i;}

Don't you have to add 3 bytes for the compiler flag?

@O.O.Balance The flag is only needed with a 64-bit version of the compiler. With a 32-bit compiler it works without the flag.

Brainfuck, (227 - 60 = 167)
+++++ +++++[>+++>++++++>+++++++++>++++++++++<<<<-]>>+++++.>>++++++++..<<<++.>>>+++++++++++++.----------.++++++.---.<<<.>>++++++++.-.>+.<++++.<<.>>----.>-.<++++.<<.>>---.+++.>------.+++.-.<++.<<.>>>++++++.-----.<<<.>>>++++++.--.

I dont think the space at the start, +++++ +++++ is needed? It could be 226 bytes.

Postscript, 364 - 40 = 324
I couldn't do it without loser, of course. :)
/${cvx exec}def
/+{<3C7E4F6F597E3E>$ $}def
/*{<~P&(~>$}def
/-{( )<3C7E4F754E7E3E>$ $ 3 4<~P#;~>$ 4 3<~P)#3FP'-~>$}def
/_{36(      )<~OoP~><3C7E4F754E7E3E>$ $ 4 3<~P,S~>$ 48<~P'?~>$
${96 3<~P#;~>$ + -}<~P">~>$}def
/.{_ 96 3<~P#;~>$ -}def
65 - 777 .
895 353 + _ 774 333 + .
74933 333 + 7 * 3 + 333 + .
9593 4353 + .
689653949 335 + .
735 333 + .
775 333 + _ 5 5 + -

This starts with encoding the text as base-36 strings:
%-=Encoding strings as base-36 numbers=-
%All your base are belong to us
% handle uppercase A separately
%36#ll = %777
%36#your = %1618515
%36#yo = 36#ur = 36#base = 36#are = 36#belong = 36#to = 36#us =
%1248 1107 527198 13946 689654284 1068 1108

And then removing the 1s and 0s and 2s arithmetically. The strings can then be regenerated with 36 <string-buf> cvrs, but this yields upper-case letters, so we then need to iterate through and add 0x20 to make them lowercase.
The operators cvx exec allow us to execute string fragments of binary-encoded operator tokens in various encodings. Simplest is to encode an operator in hex <92??> but there's a 2 in there! So the "first-level" encoding is ascii85. Then any strings that still contained forbidden characters went through extra levels of hex -> ascii85 -> hex -> ascii85.

JavaScript
(306 characters - 60 bonus = 246) (206 characters - 50 bonus = 156)
(123 chars = 173 chars - 50 bonus)
Kind of nooby, probably could get more off... Let me know if I've stuffed something up, this alerts "All your base are belong to us". This is also ASCII-only.
(c=(''+!'')[4-3],x=([][3]+c)[6])[a='c\x6F'+x+'\x73t'+c+'uct\x6F'+c][a]('a\x6C\x65'+c+'t("A\x6C\x6C y\x6Fu'+c+' ba\x73\x65 a'+c+'\x65 b\x65\x6C\x6F'+x+'\x67 t\x6F u\x73")')()

If you count the console itself as output, this would also count (57 with bonus):
'A\x6C\x6C y\x6Fu'+(c=(''+!'')[4-3])+' ba\x73\x65 a'+c+'\x65 b\x65\x6C\x6F'+([][3]+c)[6]+'\x67 t\x6F u\x73'

Great approach, though a few letter subsitutions could have also allowed you the Rule-1 bonus as well... Good work.

@WallyWest: Thanks! The problem in JavaScript is that it's rather hard to get an "A" without breaking the other rules or using up way too many characters -- it would take up more than 10 characters alone.

True, you have to outweight the additional letters against the bonuses... Nice work though!

x=(c.t+c)[6] is a bit shorter

also, eval might be easier to hack

and to get a, you can use NaN.   For A, you can use ([].constructor).toString()[9]

...which is letter_a=(+{}+c)[1] and letter_A=([][a]+c)[9]

Please could someone explain how that actually alerts anything?

Brainfuck, 306 - 60 = 246
----[---->+<]>++.[--->+<]>+..[++>---<]>--.--[->++++<]>+.----------.++++++.---.[-->+++++<]>+++.[--->+<]>++.-.--[--->+<]>--.++++[->+++<]>.--[--->+<]>-.[--->+<]>+.--[--->+<]>---.-------------.--[--->+<]>-.[--->+<]>++.+++.+++++++.+++.-.-------.-[--->+<]>--.---[->++++<]>.-----.[--->+<]>-----.---[->++++<]>+.--.

Surely this could be reduced somehow?

@WallyWest I don't have the time to reduce a program like this by 5% for no reason :P feel free to post improvements, though!

No obligation needed here :)

@WallyWest You're right about shortening it though. It could use some major improvements.

PHP (35 - 60 = -25 bytes)
HOW LOW CAN YOU GET ?[1][2]
$ xxd yourbase.php
0000000: 3c3f 3d7e be93 93df 8690 8a8d df9d 9e8c  <?=~............
0000010: 9adf 9e8d 9adf 9d9a 9390 9198 df8b 90df  ................
0000020: 8a8c 3b                                  ..;

[1] This program can be decoded using xxd -r.
[2] Yeah, heavy solution reuse here. I think it's... third problem I solved this way. Perhaps I should move to something else, but it's not that this is not great for problems that forbid you from using most characters.

I don't get it, what are you trying to do here?

@WallyWest He bit-inverted the string; resulting in 31 extended ASCII chars, which PHP tries to interprete as a constant name and because it finds no such constant interpretes as a string. This string gets negated back with ~.

Bash, 52 - 10 - 30 = 12
The following is to be executed in a (still pretty common) ISO-8859-1 environment:
$'\x74r' À-þ  @-~<<<'Áìì ùïõò âáóå áòå âåìïîç ôï õó'

This calls tr, which translates the characters in a suitable way. I had to either use the r and violate rule 2, or use a digit in the escape and violate rule 3. Since 3 gives more bonus, I chose the former.

Yes he did :) You cannot use "a", "b", "t", "u", or "y" in any case Also you need minimum two of the conditions

@cowls: Seems I completely missed that point, thanks for making it clear. Rewrote my answer to comply with that.

@MvG great re-work... Well done!

Does tr constitute an external resource?

@DigitalTrauma: More like a standard library, I'd say, although this is sure subject to interpretation. But it's specified in the POSIX standard, so I guess any POSIX system has to have it, so it's part of the system.

Interesting - I get varying results.  100% correct on OSX.  All-caps on some old redhat with tr (coreutils) 5.2.1.  This on Ubuntu 12.04 with tr (GNU coreutils) 8.13: ~B~m~m ~z~p~v~s ~c~b~t~f ~b~s~f ~c~f~m~p~o~h ~u~p ~v~t, i.e. the character values are 1 higher than they should be.

@MvG - BTW If you want to drop the r in tr and get the extra -20 bonus, you can borrow from my answer http://codegolf.stackexchange.com/a/19421/11259 z=({m..v});$'\x74'${z[5]} À-þ  @-~<<<'Áìì ùïõò âáóå áòå âåìïîç ôï õó'.  63 chars - 60 bonus = 3 (on OSX at least ;-))

OK, I guess I need to set the ISO-8859-1 environment in Linux somehow - any ideas?

@DigitalTrauma: What I did was LC_ALL=de_DE xterm, relying on the fact that plain old xterm likely doesn't support unicode in any case, and the LC_ALL override should tell it not to use Unicode even if it were supported. locale -a will list installed locales, and with a bit of luck there are some using ISO-8859-1 among these.

@MvG - yep, sudo locale-gen de_DE then LC_ALL=de_DE xterm did the trick for me

Pure Bash (no external resources), 141 chars - 50 bonus = 91

Z=({k..v})
f=$'\x65'
h=$'\x6c'
i=$'\x6f'
j=${Z[7]}
k=$'\x73'
m=$'\x75'
$f$'\x63'h$i A$h$h y$i$m$j ba$k$f a$j$f b$f$h$i${Z[3]}$'\x67' t$i u$k

Intentionally dropping the 10-point bonus to get a better overall score.
This works on any bash version 3.00.15 or later that I have tried.
How does it work
There's no rocket science here - just bash expansions of one form or another:

Simple hex expansion to obtain required character.  This works for characters whose hex representation doesn't contain [012].  e.g. $'\x65' gives us e
For other characters, we generate a bash array of sequential characters using brace expansion into an array initialization (Z=({k..v})).  The start of the brace expansion is chosen carefully so that the indexes of the characters we require don't contain [012].  e.g.
${Z[7]} gives us r.
bash is flexible enough to allow its commands to be constructed from the contents of multiple strings.  So $f$'\x63'h$i expands to echo.
For characters that are required only once, the expansion is inserted inline to the echo command string.
For characters that are required twice or more it is more efficient to expand them to variables, then reference the variables.

Previous answer with full bonus, but worse overall score:
Pure Bash (no external resources), 193 chars - 60 bonus = 133
I know this won't win, but I wanted to prove to myself this is possible in bash, while satisfying all requirements:

Z=({3..8} {C..z})
c=${Z[36]}
d=${Z[37]}
f=$'\x65'
h=$'\x6c'
i=$'\x6f'
j=${Z[53]}
k=$'\x73'
m=$'\x75'
$f$'\x63'h$i ${c^}$h$h $'\x79'$i$m$j $d$c$k$f $c$j$f $d$f$h$i${Z[49]}$'\x67' $'\x74'$i $m$k

This does require a fairly recent version of bash for the ${c^} parameter expansion.  4.2.25 is fine, but 3.2.48 is a no-go.

I take my hat off to you... I just executed this... nice work... Very nice work.

@WallyWest - I just edited in a shorter version.

Jelly, 23 - 60 = -37
“%⁼“¡¢8ṣƤ¹;“pȷȦÆ⁾“¡PȤṫ»

Try it online!
This is just the compressed representation of ["All", " your base are", " belong to", " us"] (Jelly has a compressed string format). The string's split into multiple pieces in order to ensure that none of the banned characters appear within the compressed representation; they're all implicitly concatenated at the end of the program.

PHP, 186 - 10 - 30 = 146
I had to get a little creative ;)
 <?=chr(65).'ll '.chr(88+33).'o'.chr(39*3).'r '.chr(98).chr(97).'s'.chr(68+33).' '.chr(97).chr(38*3).chr(68+33).' '.chr(98).'elo'.chr(77+33).chr(69+34).' '.chr(83+33).'o '.chr(39*3).'s'?>

you could still golf it a little and mantain the answer idea: echo doesn't require parentheses(1), you can use <?= instead of echo(4), you can save the repeated letters in variables ('l', ' '). use 54*2 instead of 54+54

Fixed. I could only do multiplying on certain ones. I can't do 54*2 because that it has a 2 in it, so I could only do it with ones that had 3 or higher has a factor. If I use a decimal, then there's no less characters.

a few golfing tips taking 50 bytes off. Most of it (23+9 bytes): You can replace the remaining chr(68+33) and chr(38*3) with literal e and r.

PHP, 67 bytes -60 bonus = 7
<?=d__cJZFFcQWFVcWFVcQV_ZZQcCZcFF^"%33C3534C3653C643C333546C75C35";

bitwise XOR on the ASCII characters
I brute forced a pair of characters not in the forbidden characters for each character in output.
No word character pair for A and I don´t like extended ASCII, so I live with one string in quotes.

Now, @Titus, how exactly does this work? I can only guess that somehow you're using some clever replace function... I've never seen this kind of witchcraft with PHP before... All I know is that it works!

@WallyWest I´ll explain inline.

The ^ symbol! Of course! I had read about PHP's XOR ability a while back but had completely forgotten about it... Nice one!

Vyxal ṡ, 20 bytes, score -40
‛λʀ«×∇⟇Ȧß¥fė₀⌊↓qεǏq⟑

Try it Online!
-4 bytes / -4 score thanks to Aaron Miller.

You’ve used an S in your code, the -20 bonus is invalid…

@EliseoD'Annunzio It specified lowercase s - 's', not capital.

Actually what I wrote in my initial brief was 'You cannot use "l", "o", "s", "e", or "r" in any case in your code (bonus -20 to your golf score if you can do this)'
Emphasis on "ANY case" as in upper or lower case...

@EliseoD'Annunzio Oh, reverting to the 23-byter. Give me a moment.

20 bytes, -40 score

BF-RLE, 146 - 30 = 116
+5[>+5<-]>+.<+4[>+3<-]>+..>>+3[<+2>-]<++.<+A.-7.+3.-0.>.<<+1[>-1<-]>.-.<+0[>+3<-]>.-B.>.<-1.<+1[>+1<-]>+.-A.>.<-0.+0.+4.+0.-.-4.>.<+A.-2.>.<+3.--.

This can be shortened significantly

Python, 181 - 40 = 141
[I'm using version 2.7.2 YMMV - the builtin, file is gone in python 3.X]
f=file.__doc__;c=5-3;l=f[c];s=' ';e=f[3];h=f[6+7];i=f[c*87];j=3**3;f[j*c*5]+l+l+s+f[-57]+h+f[j-7]+f[j-3]+s+f[j-8]+f[6]+i+e+s+f[6]+f[j-3]+e+s+f[j-8]+e+l+h+f[5]+f[j]+s+f[45]+h+s+f[j-7]+i

Python (104 - 30 = 74)
>>> '\x41\x6c\x6c \x79\x6f\x75\x72 \x62\x61\x73\x65 \x61\x72\x65 \x62\x65\x6c\x6f\156\x67 \x74\x6f \x75\x73'
'All your base are belong to us'

And score:
>>> len(r"'\x41\x6c\x6c \x79\x6f\x75\x72 \x62\x61\x73\x65 \x61\x72\x65 \x62\x65\x6c\x6f\156\x67 \x74\x6f \x75\x73'")-30
74

Nicely done, but you really didn't need to do the same for determining the score... ;)

Mumps, 150 - 60 = 90. 40 = 110
S J=" ",Z=36*3,C=37*3,D=38*3,Q=39*3,I=35*3-4 W *65,*Z,*Z,J,*484/4,*C,*Q,*D,J,*98,*97,*C+4,*I,J,*97,*D,*I,J,*98,*I,*Z,*C,*D-4,*Z-5,J,*C+5,*C,J,*Q,*C+4

I'm not sure if it could have been done shorter (overall) by not getting one of the code bonuses - my goal was a bit less on shortness and a bit more on the -60... I liked the challenge of not using any of the restricted characters.
And... I goofed it up - missed the beginning 'S' command. :-/
Anyway, here's a "no rules" version - expanding the variables.
W *65,*36*3,*36*3," ",*484/4,*37*3,*39*3,*38*3," ",*98,*97,*37*3+4,*35*3-4," ",*97,*38*3,*35*3-4," ",*98,*35*3-4,*36*3,*37*3,*38*3-4,*36*3-5," ",*37*3+5,*37*3," ",*39*3,*37*3+4

And that gives it a score of 177-60 = 117. So breaking the center rule still gave me a lower overall score.

Interesting answer... Is there an online emulator I can access to execute this code?

Not to my knowledge, but there are versions for Mumps that run on just about every platform - there's even versions that will run on a Raspberry Pi if you want a very small Mumps machine... :-)

Perl 5, 99 − 50 = 49
A subroutine that returns the required string:
{A.($c=h|d)."$c y".($f=f|k).u.($k=p|b)." ba".($j=c|p).($d=d|a)." a$k$d b$d$c$f".(jf|fc)." t$f u$j"}

See it printed thus:
perl -e'print sub{...}->().$/'

SmileBASIC, 149 bytes -30 -10 = 109
L$=CHR$(&H75)O$=CHR$(98)S$=CHR$(97)?CHR$(65);"ll",CHR$(&H79);"o";L$;"r ";O$;S$;"se ";S$;"re ";O$;"elo";CHR$(&H6E);CHR$(&H67);" ";CHR$(&H74);"o",L$;"s

VBA, 119 - 40 = 79 Bytes
Anonymous VBE Immediate window function that takes no input and outputs All your base are belong to us to the VBE immediate window
L=Chr(&H75):O=Chr(98):S=Chr(97):?Chr(65)"ll "Chr(&H79)"o"L"r "O;S"se "S"re "O"elo"Chr(&H6E)Chr(&H67)" "Chr(&H74)"o "L"s

This is largely a port of 12Me21's SmileBASIC Answer - Hooray for BASIC languages

Whitespace, 194 (254 bytes - 60 bonus)
[S S S T    S T S N
_Push_10_s][S S S T T   S S N
_Push_12_u][S S T   T   S S T   S S T   N
_Push_-73_space][S S S T    T   S N
_Push_6_o][S S S T  S T T   N
_Push_11_t][S T S S T   S N
_copy_2nd_space][S S T  T   S N
_Push_-2_g][S S S T S T N
_Push_5_n][S S S T  T   S N
_Push_6_o][S S S T  T   N
_Push_3_l][S S T    T   S S N
_Push_-4_e][S S T   T   T   T   N
_Push_-7_b][S S T   T   S S T   S S T   N
_Push_-73_space][S S T  T   S S N
_Push_-4_e][S S S T S S T   N
_Push_9_r][S S T    T   S S S N
_Push_-8_a][S T S S T   T   N
_Copy_3rd_space][S S T  T   S S N
_Push_-4_e][S S S T S T S N
_Push_10_s][S S T   T   S S S N
_Push_-8_a][S S T   T   T   T   N
_Push_-7_b][S T S S T   S S N
_Copy_4th_space][S S S T    S S T   N
_Push_9_r][S S S T  T   S S N
_Push_12_u][S S S T T   S N
_Push_6_o][S S S T  S S S S N
_Push_17_y][S T S S T   S S N
_Copy_4th_space][S S S T    T   N
_Push_3_l][S N
S _Duplicate_8_l][S S T T   S T S S S N
_Push_-40_A][N
S S N
_Create_Label_LOOP][S S S T T   S T S S T   N
_Push_105][T    S S S _Add][T   N
S S _Print_as_character][N
S N
N
_Jump_to_Label_LOOP]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Try it online (raw with spaces, tabs, and new-lines only).
Uses the shorter alternative I've explained in the bottom of this Whitespace tip, with the fixed amount being 105 in this case.

Very nice... I've was wondering when I've was going to see an esoteric answer creeping in!

Pxem, Filename: 45 bytes + Content: 0 bytes - Bonus: 30 bytes = 15 bytes.

Filename (escaped some characters): Xx\202\330\330\100\362\336\352\344\100\304\302\346\312\100\302\344\312\100\304\312\330\336\334\316\100\350\336\100\352\346!.z\002.$.o.c!.a

Printed version: Xx‚ØØ@òÞêä@ÄÂæÊ@ÂäÊ@ÄÊØÞÜÎ@èÞ@êæ!.z.$.o.c!.a

Content: empty

What it does

Twice necesity ASCII codes before.
Halve on this program.

Try it online!

Pxem, Filename: 55 bytes + Content: 0 bytes - Bonus: 50 bytes = 5 bytes.

Filename (escaped some): Xx\202\330\330\100\362\336\352\344\100\304\302\346\312\100\302\344\312\100\304\312\330\336\334\316\100\350\336\100\352\346!.z\002.$.t.v.m.v.c!.a.t.p

Printed: XxØØ@òÞêä@ÄÂæÊ@ÂäÊ@ÄÊØÞÜÎ@èÞ@êæ!.z.$.t.v.m.v.c!.a.t.p

Content: empty

What it does

Move to bottom each of them.
Hide last ! to heap.
Print all of them at once.

Try it online!

05AB1E, 18 - 60 = -42 bytes
“€Ÿ€žŠà€™ÊÂ€„€ª“.ª

Try it online!
“...“.ª  # trimmed program
“...“    # push "all your base are belong to us"...
     .ª  # in sentence case
         # implicit output

Deadfish~, 232 − 40 = 192 238 − 60 = 178 bytes
{iiiiii}iiiiic{iiii}iiicc{{d}ii}iiiic{{i}d}dc{d}ciiiiiicdddc{{d}ii}ddc{{i}ddd}ddddcdc{ii}ddc{d}ddddc{{d}iii}ic{{i}ddd}dddddc{ii}dddc{d}dddc{{d}iii}ic{{i}ddd}ddddciiic{i}dddciiicdc{d}iiic{{d}iii}dc{{i}dd}iiiicdddddc{{d}ii}ic{{i}d}dddddcddc

Try it online!

Perl 5, 80 bytes - 60 = 20
Claiming all three bonuses.
('3?"5W939=8#>/'^p x$].J x 8)->($~,';66z#5/(z8;)?z;(?z8?654=z.5z/)'^z.Z x(33-4))

Try it online!
Explanation
Builds up the strings: CORE'syswrite and All your base are belong to us using the stringwise XOR operator with repeated strings where available, calling these strings as function references passing $~ as the first argument to syswrite and the All your base... string as the second.

Perl 5, 58 bytes - 60 = -2
This one contains mostly unprintables and utilises the inverse binary string operator ~.
(~'.............')->($~,~'..............................')

Try it online!

Python 96 - 40 = 56
exec("z='';[z:=z+chr(ord(x)^(34-3))for x i\x6e'^ss?fpjm?}~lz?~mz?}zspqx?kp?jl'];pri\x6e\x74(z)")

Or with REPR 83 - 40 = 43
exec("z='';[z:=z+chr(ord(x)^(34-3))for x i\x6e'^ss?fpjm?}~lz?~mz?}zspqx?kp?jl']");z

Aceto, 23 bytes
3rd grade Hilbert curve, 53 bytes - 30 bonus = 23.
lo'm"  u
e"poptos
b cIcIp"
rep'fo
asab
 er
Aluo
"l y

50-30=20

Japt, 33 - 60 = -27 bytes
`mßPÚXmÞ-ãù“`i`à ö` d"m " Å
i°Id

Try it online!
The shoco library is powerful at compressing lowercase letters, but I had to do lots of experiment in order to get a compressed string without any of the banned chars.
Unpacked & How it works
`mßPÚXmÞ-ãù“`i`à ö` d"m " s1
`mßPÚXmÞ-ãù“`                 "mbasemarembelongmtomus"
              i`à ö`           Insert "allmyour" at the beginning
                     d"m "     Replace "m" with " "
                           s1  Discard initial "a"
                               Implicitly assign to U

Ui++Id
Ui      Add to the beginning of U...
  ++I     65
     d    chr(65) == "A"

29 bytes

25 bytes

Google Sheets, 53 - 30 = 23
Speaking of Bases... Following rules 1 & 2:
="All your base are belo"&LOWER(BASE(775,33))&" to us

I believe this is optimal, unless the string can be compressed.

Applying all three rules does not leave us with any useful functions. These are IMDIV, FV, PV, IF, PI, PHI, and MID. MID is almost interesting: we can gain access to [TRUEFALS] because we can do comparisons to get boolean strings, but this leaves way too many letters out.
Similarly, even following two rules, we still don't have access to any useful alphabetic character yielding functions. (CHAR, BASE, TEXT)
This means that we have to follow one rule or bust. I choose the most valuable one, [NG012]. Luckily the phrase only contains an illegal "ng", which we can easily get around with BASE.
An alternative solution is to split all words by spaces into a column, then join by spaces, but that results in the same score and is harder to set up.

Python 3, 104 - 50 = 54 bytes
quit("A\x6C\x6C y\x6Fu%()c ba\x73\x65 a%()c\x65 b\x65\x6C\x6F%(#)c\x67 t\x6F u\x73"%{'':3*38,'#':77+33})

Try it online!
Prints the output to STDERR, which is allowed as stated on the I/O meta post. Uses a combination of plain characters, hexadecimal strings and some C-style string formatting with some addition and multiplication to avoid 0-2.

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


text:
Partition a map of water flows
This is a challenge on the internet asked by Palantir Technologies in their interviews.

A group of farmers has some elevation data, and we’re going to help
  them understand how rainfall flows over their farmland.  We’ll
  represent the land as a two-dimensional array of altitudes and use the
  following model, based on the idea that water flows downhill:
If a cell’s four neighboring cells all have higher altitudes, we call
  this cell a sink; water collects in sinks.  Otherwise, water will flow
  to the neighboring cell with the lowest altitude. If a cell is not a
  sink, you may assume it has a unique lowest neighbor and that this
  neighbor will be lower than the cell.
Cells that drain into the same sink – directly or indirectly – are
  said to be part of the same basin.
Your challenge is to partition the map into basins. In particular,
  given a map of elevations, your code should partition the map into
  basins and output the sizes of the basins, in descending order.
Assume the elevation maps are square. Input will begin with a line
  with one integer, S, the height (and width) of the map. The next S
  lines will each contain a row of the map, each with S integers – the
  elevations of the S cells in the row. Some farmers have small land
  plots such as the examples below, while some have larger plots.
  However, in no case will a farmer have a plot of land larger than S =
  5000.
Your code should output a space-separated list of the basin sizes, in
  descending order. (Trailing spaces are ignored.)
A few examples are below.
Input:

3
1 5 2
2 4 7
3 6 9

Output:  7 2
The basins, labeled with A’s and B’s, are:

A A B
A A B
A A A

Input:

1
10

Output:  1
There is only one basin in this case.
Input:

5
1 0 2 5 8
2 3 4 7 9
3 5 7 8 9
1 2 5 4 2
3 3 5 2 1

Output:  11 7 7
The basins, labeled with A’s, B’s, and C’s, are:

A A A A A
A A A A A
B B A C C
B B B C C
B B C C C

Input:

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

Output:  7 5 4
The basins, labeled with A’s, B’s, and C’s, are:

A A B B
A B B B
A B B C
A C C C

I edited your question to make it more appropriate for this site. Earlier, it was a programming question / code review. Now it is in the form of the challenge. This site is for releasing code challenges / problems to the community for them to attempt. Note: you still require a winning criteria: shortest code ([tag:code-golf]) is recommended.

I am going to take the liberty of marking your question code-golf.

@OP If you want an answer for your original question instead of a number of alternative golfed solutions, I suggest asking it again on Stack Overflow (or maybe Code Review?)

@Gareth codereview doesn't like golfing and SO doesn't like reviewing, so...

@JanDvorak I think the original question before editing might be okay on Code Review (there wasn't any golfing involved to start with)? You're probably right about SO though.

@Quincunx The part please make an effort to submit clean, readable code rules out any code-golf.

CR is it, then. But, what should be done about this question? The quoted goals don't  match code-golf, otherwite it seems fine to me. Just edit them out?

@JanDvorak I think just edit it out and make it a valid code-golf

I have posted the problem on code review - http://codereview.stackexchange.com/questions/39895/how-to-partition-a-2d-map-consisting-of-elevation-data-into-individual-basins

Mathematica
The basin size list can be gotten by
WatershedComponents[
 Image[Rest@ImportString[m,"Table"]] // ImageAdjust,
 CornerNeighbors -> False,
 Method -> "Basins"
 ] // Reverse@Sort@Part[Tally[Flatten@#], All, 2] &

where m is the given input data. To display a matrix like the ones in the question one can replace // Reverse@Sort@Part[Tally[Flatten@#], All, 2] & with /. {1 -> "A", 2 -> "B", 3 -> "C"} // MatrixForm or one can display it as an image instead using //ImageAdjust//Image.

Don't leave us hanging! The sorted basin size list would use BinCounts[] & Sort[], right?

@ScottLeadley I didn't realize it was the basin size list that was requested, thank you for pointing that out. I've fixed the answer (although the last part can probably be made a lot shorter).

JavaScript - 673 707 730 751
e=[],g=[],h=[],m=[],q=[];function r(){a=s,b=t;function d(d,A){n=a+d,p=b+A;c>e[n][p]&&(u=!1,v>e[n][p]&&(v=e[n][p],w=n,k=p))}c=e[a][b],u=!0,v=c,w=a,k=b;0!=a&&d(-1,0);a!=l&&d(1,0);0!=b&&d(0,-1);b!=l&&d(0,1);g[a][b]=w;h[a][b]=k;return u}function x(a,b,d){function c(a,b,c,k){g[a+b][c+k]==a&&h[a+b][c+k]==c&&(d=x(a+b,c+k,d))}d++;0!=a&&c(a,-1,b,0);a!=l&&c(a,1,b,0);0!=b&&c(a,0,b,-1);b!=l&&c(a,0,b,1);return d}y=$EXEC('cat "'+$ARG[0]+'"').split("\n");l=y[0]-1;for(z=-1;z++<l;)e[z]=y[z+1].split(" "),g[z]=[],h[z]=[];for(s=-1;s++<l;)for(t=-1;t++<l;)r()&&m.push([s,t]);for(z=m.length-1;0<=z;--z)s=m[z][0],t=m[z][1],q.push(x(s,t,0));print(q.sort(function(a,b){return b-a}).join(" "));
Test results (using Nashorn):
$ for i in A B C D; do jjs -scripting minlm.js -- "test$i"; done
7 2
1
11 7 7
7 5 4
$

There would probably be stack problems for maps of size 5000 (but that's an implementation detail :).

The unminified source in all it's fugliness:
// lm.js - find the local minima

//  Globalization of variables.

/*
    The map is a 2 dimensional array. Indices for the elements map as:

    [0,0] ... [0,n]
    ...
    [n,0] ... [n,n]

Each element of the array is a structure. The structure for each element is:

Item    Purpose         Range       Comment
----    -------         -----       -------
h   Height of cell      integers
s   Is it a sink?       boolean
x   X of downhill cell  (0..maxIndex)   if s is true, x&y point to self
y   Y of downhill cell  (0..maxIndex)

Debugging only:
b   Basin name      ('A'..'A'+# of basins)

Use a separate array-of-arrays for each structure item. The index range is
0..maxIndex.
*/
var height = [];
var sink = [];
var downhillX = [];
var downhillY = [];
//var basin = [];
var maxIndex;

//  A list of sinks in the map. Each element is an array of [ x, y ], where
// both x & y are in the range 0..maxIndex.
var basinList = [];

//  An unordered list of basin sizes.
var basinSize = [];

//  Functions.

function isSink(x,y) {
    var myHeight = height[x][y];
    var imaSink = true;
    var bestDownhillHeight = myHeight;
    var bestDownhillX = x;
    var bestDownhillY = y;

    /*
        Visit the neighbors. If this cell is the lowest, then it's the
    sink. If not, find the steepest downhill direction.

        This would be the place to test the assumption that "If a cell
    is not a sink, you may assume it has a unique lowest neighbor and
    that this neighbor will be lower than the cell." But right now, we'll
    take that on faith.
    */
    function visit(deltaX,deltaY) {
        var neighborX = x+deltaX;
        var neighborY = y+deltaY;
        if (myHeight > height[neighborX][neighborY]) {
            imaSink = false;
            if (bestDownhillHeight > height[neighborX][neighborY]) {
                bestDownhillHeight = height[neighborX][neighborY];
                bestDownhillX = neighborX;
                bestDownhillY = neighborY;
            }
        }
    }
    if (x !== 0) {
        // upwards neighbor exists
        visit(-1,0);
    }
    if (x !== maxIndex) {
        // downwards neighbor exists
    visit(1,0);
    }
    if (y !== 0) {
        // left-hand neighbor exists
        visit(0,-1);
    }
    if (y !== maxIndex) {
        // right-hand neighbor exists
        visit(0,1);
    }

    downhillX[x][y] = bestDownhillX;
    downhillY[x][y] = bestDownhillY;
    return imaSink;
}

function exploreBasin(x,y,currentSize) {//,basinName) {
    //  This cell is in the basin.
    //basin[x][y] = basinName;
    currentSize++;

    /*
        Visit all neighbors that have this cell as the best downhill
    path and add them to the basin.
    */
    function visit(x,deltaX,y,deltaY) {
        if ((downhillX[x+deltaX][y+deltaY] === x) && (downhillY[x+deltaX][y+deltaY] === y)) {
            currentSize = exploreBasin(x+deltaX,y+deltaY,currentSize); //,basinName);
        }
        return 0;
    }
    if (x !== 0) {
        // upwards neighbor exists
        visit(x,-1,y,0);
    }
    if (x !== maxIndex) {
        // downwards neighbor exists
        visit(x,1,y,0);
    }
    if (y !== 0) {
        // left-hand neighbor exists
        visit(x,0,y,-1);
    }
    if (y !== maxIndex) {
        // right-hand neighbor exists
        visit(x,0,y,1);
    }

    return currentSize;
}

//  Read map from file (1st argument).
var lines = $EXEC('cat "' + $ARG[0] + '"').split('\n');
maxIndex = lines.shift() - 1;
for (var i = 0; i<=maxIndex; i++) {
    height[i] = lines.shift().split(' ');
    //  Create all other 2D arrays.
    sink[i] = [];
    downhillX[i] = [];
    downhillY[i] = [];
    //basin[i] = [];
}

//  Everyone decides if they are a sink. Create list of sinks (i.e. roots).
for (var x=0; x<=maxIndex; x++) {
    for (var y=0; y<=maxIndex; y++) {
        if (sink[x][y] = isSink(x,y)) {
            //  This node is a root (AKA sink).
            basinList.push([x,y]);
        }
    }
}
//for (var i = 0; i<=maxIndex; i++) { print(sink[i]); }

//  Each root explores it's basin.
//var basinName = 'A';
for (var i=basinList.length-1; i>=0; --i) { // i-- makes Closure Compiler sad
    var x = basinList[i][0];
    var y = basinList[i][1];
    basinSize.push(exploreBasin(x,y,0)); //,basinName));
    //basinName = String.fromCharCode(basinName.charCodeAt() + 1);
}
//for (var i = 0; i<=maxIndex; i++) { print(basin[i]); }

//  Done.
print(basinSize.sort(function(a, b){return b-a}).join(' '));

I got better minimization results by breaking up the element objects into separate arrays, globalizing everywhere possible and embracing side-effects. NSFW.

The effects of code minimization:

4537 bytes, unminified
1180 bytes, packer
855 bytes, packer + hand optimizations (1 character global names)
751 bytes, Google Closure Compiler with ADVANCED_OPTIMIZATIONS (NB, it elided a vestigial "return 0" as dead code)
730 bytes, reckless hand optimization (I'm not changing the unminified source, so NSFW)
707 bytes, more reckless hand optimization (remove all references to sink[]);
673 bytes, remove all "var"s, drop Nashorn -strict flag

I could have achieved close to 700 bytes without editing the minimized code if I'd been willing to modify the original source. But I didn't because I think leaving it as-is gives an interesting view from the starting point.

You can shorten var e=[],g=[],h=[],l,m=[],q=[] to e=g=h=l=m=q=[]. You can probably get rid of other uses of the var keyword too if you aren't shadowing any global variables.

@nyuszika7h No can do. e=g=h=l=m=q=[] would have them all using a pointer to the same array. And Nashorn requires the var.

@nyuszika7h You kicked my out of my rut. I dropped Nashorn -strict and deleted all the "var"s.

Ruby, 216
r=[]
M=gets('').split.map &:to_i
N=M.shift
g=M.map{1}
M.sort.reverse.map{|w|t=[c=M.index(w),c%N<0?c:c-1,c%N<N-1?c+1:c,c+N,c-N].min_by{|y|M[y]&&y>=0?M[y]:M.max}
M[c]+=1
t!=c ?g[t]+=g[c]:r<<g[c]}
$><<r.sort.reverse*' '

It's a slightly different approach, only invoking "flow" on each square once (performance depends what the performance of Array::index is).  It goes from the highest elevation to the lowest, emptying out one cell at a time into its lowest neighbor and marking the cell done (by adding 1 to the elevation) when it's done.
Commented and spaced:
results=[]
ELEVATIONS = gets('').split.map &:to_i  # ELEVATIONS is the input map
MAP_SIZE = ELEVATIONS.shift             # MAP_SIZE is the first line of input
watershed_size = ELEVATIONS.map{1}      # watershed_size is the size of the watershed of each cell

ELEVATIONS.sort.reverse.map { |water_level|
    # target_index is where the water flows to.  It's the minimum elevation of the (up to) 5 cells:
    target_index = [
        current_index = ELEVATIONS.index(water_level),                              # this cell
        (current_index % MAP_SIZE) < 0           ? current_index : current_index-1, # left if possible
        (current_index % MAP_SIZE) >= MAP_SIZE-1 ? current_index : current_index+1, # right if possible
        current_index + MAP_SIZE,                                                   # below
        current_index - MAP_SIZE                                                    # above
    ].min_by{ |y|
        # if y is out of range, use max. Else, use ELEVATIONS[y]
        (ELEVATIONS[y] && y>=0) ? ELEVATIONS[y] : ELEVATIONS.max
    }
# done with this cell.
# increment the elevation to mark done since it no longer matters
ELEVATIONS[current_index] += 1

# if this is not a sink
(target_index != current_index) ?
    # add my watershed size to the target's
    watershed_size[target_index] += watershed_size[current_index]
    # else, push my watershed size onto results
    : results << watershed_size[current_index]}

Changelog:
216 - better way to deselect out-of-bounds indices
221 - turns out, "11" comes before "2"... revert to to_i, but save some space on our getses.
224 - Why declare s, anyway?  And each => map
229 - massive golfing - sort the elevations first into s (and thereby drop the while clause), use min_by instead of sort_by{...}[0], don't bother to_i for elevations, use flat_map, and shrink select{} block
271 - moved watershed size into new array and used sort_by
315 - moved results to array which gave all sorts of benefits, and shortened neighbor index listing. also gained one char in index lambda.
355 - first commit

Haskell, 271 286
import Data.List
m=map
q[i,j]=[-1..1]>>= \d->[[i+d,j],[i,j+d]]
x%z=m(\i->snd.fst.minimum.filter((`elem`q i).snd)$zip(zip z[0..])x)x
g(n:z)=iterate(\v->m(v!!)v)(sequence[[1..n],[1..n]]%z)!!(n*n)
main=interact$unwords.m show.reverse.sort.m length.group.sort.g.m read.words

Might be still some code to be golf'd here.
& runhaskell 19188-Partition.hs <<INPUT
> 5
> 1 0 2 5 8
> 2 3 4 7 9
> 3 5 7 8 9
> 1 2 5 4 2
> 3 3 5 2 1
INPUT
11 7 7

Explanation
Basic idea: For each cell (i,j) find the lowest cell in the "neighborhood". This
gives a graph [(i,j) → (mi,mj)]. If a cell is the lowest cell itself, then
(i,j) == (mi,mj).
This graph can be iterated: For each a → b in the graph, replace it with a → c
where b → c is in the graph. When this iteration yields no more changes, then
each cell in the graph points at the lowest cell it will flow to.
To golf this, several changes have been made: First, coordinates are represented
as a list of length 2, rather than a pair. Second, once the neighbors have been
found, cells are represented by their index into a linear array of the cells,
not 2D coordinates. Third, as there are n*n cells, after n*n iterations, the
graph must be stable.
Ungolf'd
type Altitude = Int     -- altitude of a cell

type Coord = Int        -- single axis coordinate: 1..n
type Coords = [Coord]   -- 2D location, a pair of Coord
    -- (Int,Int) would be much more natural, but Coords are syntehsized
    -- later using sequence, which produces lists

type Index = Int        -- cell index
type Graph = [Index]    -- for each cell, the index of a lower cell it flows to

neighborhood :: Coords -> [Coords]                              -- golf'd as q
neighborhood [i,j] = concatMap (\d -> [[i+d,j], [i,j+d]]) [-1..1]
    -- computes [i-1,j] [i,j-1] [i,j] [i+1,j] [i,j+1]
    -- [i,j] is returned twice, but that won't matter for our purposes

flowsTo :: [Coords] -> [Altitude] -> Graph                      -- golf'd as (%)
flowsTo cs vs = map lowIndex cs
  where
    lowIndex is = snd . fst                          -- take just the Index of
                  . minimum                          -- the lowest of
                  . filter (inNeighborhood is . snd) -- those with coords nearby
                  $ gv                               -- from the data

    inNeighborhood :: Coords -> Coords -> Bool
    inNeighborhood is ds = ds `elem` neighborhood is

    gv :: [((Altitude, Index), Coords)]
        -- the altitudes paired with their index and coordinates
    gv = zip (zip vs [0..]) cs

flowInput :: [Int] -> Graph                                     -- golf'd as g
flowInput (size:vs) = iterate step (flowsTo coords vs) !! (size * size)
  where
    coords = sequence [[1..size],[1..size]]
        -- generates [1,1], [1,2] ... [size,size]

    step :: Graph -> Graph
    step v = map (v!!) v
        -- follow each arc one step

main' :: IO ()
main' = interact $
            unwords . map show      -- counts a single line of text
            . reverse . sort        -- counts from hi to lo
            . map length            -- for each common group, get the count
            . group . sort          -- order cells by common final cell index
            . flowInput             -- compute the final cell index graph
            . map read . words      -- all input as a list of Int

It'd be great if you could explain what's going on here.

@Charles - done!

Julia, 315
function f(a,i,j)
    z=size(a,1)
    n=filter((x)->0<x[1]<=z&&0<x[2]<=z,[(i+1,j),(i-1,j),(i,j-1),(i,j+1)])
    v=[a[b...] for b in n]
    all(v.>a[i,j]) && (return i,j)
    f(a,n[indmin(v)]...)
end
p(a)=prod(["$n " for n=(b=[f(a,i,j) for i=1:size(a,1),j=1:size(a,2)];sort([sum(b.==s) for s=unique(b)],rev=true))])

Just a recursive function that either determines the current cell is a sink or finds the drain, then call that on every set of indices.  Didn't bother to do the input part since I wasn't going to win anyway, and that part isn't fun.

Python: 276 306 365 bytes
This is my first golf attempt. Suggestions are appreciated!
edit: imports and closing files take too many characters! So does storing files in variables and nested list comprehension.
t=map(int,open('a').read().split());n=t.pop(0);q=n*n;r,b,u=range(q),[1]*q,1
while u!=0:
    u=0
    for j in r:
        d=min((t[x],x)for x in [j,j-1,j+1,j-n,j+n]if int(abs(j/n-x/n))+abs(j%n-x%n)<=1 and x in r)[1]
        if j-d:u|=b[j];b[d]+=b[j];b[j]=0
for x in sorted(b)[::-1]:print x or '',

fully commented (2130 bytes...)
from math import floor
with open('a') as f:
    l = f.read()
    terrain = map(int,l.split()) # read in all the numbers into an array (treating the 2D array as flattened 1D)
    n = terrain.pop(0) # pop the first value: the size of the input
    valid_indices = range(n*n) # 0..(n*n)-1 are the valid indices of this grid
    water=[1]*(n*n) # start with 1 unit of water at each grid space. it will trickle down and sum in the basins.
    updates=1 # keep track of whether each iteration included an update

    # helper functions
    def dist(i,j):
        # returns the manhattan (L1) distance between two indices
        row_dist = abs(floor(j/n) - floor(i/n))
        col_dist = abs(j % n - i % n)
        return row_dist + col_dist

    def neighbors(j):
        # returns j plus up to 4 valid neighbor indices
        possible = [j,j-1,j+1,j-n,j+n]
        # validity criteria: neighbor must be in valid_indices, and it must be one space away from j
        return [x for x in possible if dist(x,j)<=1 and x in valid_indices]

    def down(j):
        # returns j iff j is a sink, otherwise the minimum neighbor of j
        # (works by constructing tuples of (value, index) which are min'd
        # by their value, then the [1] at the end returns its index)
        return min((terrain[i],i) for i in neighbors(j))[1]

    while updates!=0: # break when there are no further updates
        updates=0 # reset the update count for this iteration
        for j in valid_indices: # for each grid space, shift its water
            d =down(j)
            if j!=d: # only do flow if j is not a sink
                updates += water[j] # count update (water[j] is zero for all non-sinks when the sinks are full!)
                water[d] += water[j] # move all of j's water into the next lowest spot
                water[j] = 0 # indicate that all water has flown out of j
    # at this point, `water` is zeros everywhere but the sinks.
    # the sinks have a value equal to the size of their watershed.
    # so, sorting `water` and printing nonzero answers gives us the result we want!
    water = sorted(water)[::-1] # [::-1] reverses the array (high to low)
    nonzero_water = [w for w in water if w] # 0 evaulates to false.
    print " ".join([str(w) for w in nonzero_water]) # format as a space-separated list

Please don't golf a year. 365 chars is too nice. :P

I got it down to 306! I need those extra 59 days of vacation time.

You should be able to just do open('a').read(), I think.

Python - 470 447 445 393 392 378 376 375 374 369 bytes
I can't stop myself!
Not a winning solution, but I had a lot of fun creating it. This version does not assume the input to be stored anywhere and instead reads it from stdin. Maximum recursion depth = longest distance from a point to it's sink.
def f(x,m=[],d=[],s=[]):
 n=[e[a]if b else 99for a,b in(x-1,x%z),(x+1,x%z<z-1),(x-z,x/z),(x+z,x/z<z-1)];t=min(n)
 if t<e[x]:r=f(x+(-1,1,-z,z)[n.index(t)])[0];s[r]+=x not in m;m+=[x]
 else:c=x not in d;d+=[x]*c;r=d.index(x);s+=[1]*c
 return r,s
z,e=input(),[]
exec'e+=map(int,raw_input().split());'*z
for x in range(z*z):s=f(x)[1]
print' '.join(map(str,sorted(s)[::-1]))

I don't have time to explain it today, but here's the ungolfed code:
It actually is quite different than the original code. I read S lines from the stdin, split, map to ints and flatten the lists to get the flattened field. Then I loop through all tiles (let me call them tiles) once. The flow-function checks the neighboring tiles and picks the one with the smallest value. If it's smaller than value of the current tile, move to it and recurse. If not, the current tile is a sink and new basin is created. The return value of the recursion is the id of the basin.
# --- ORIGINAL SOURCE ---

# lowest neighboring cell = unique and next
# neihboring cells all higher = sink and end

basinm = [] # list of the used tiles
basins = {} # list of basin sizes
basinf = [] # tuples of basin sinks
field = []  # 2d-list representing the elevation map
size = 0

def flow(x, y):
    global basinf, basinm
    print "Coordinate: ", x, y
    nearby = []
    nearby += [field[y][x-1] if x > 0 else 99]
    nearby += [field[y][x+1] if x < size-1 else 99]
    nearby += [field[y-1][x] if y > 0 else 99]
    nearby += [field[y+1][x] if y < size-1 else 99]
    print nearby
    next = min(nearby)
    if next < field[y][x]:
        i = nearby.index(next)
        r = flow(x+(-1,1,0,0)[i], y+(0,0,-1,1)[i])
        if (x,y) not in basinm:
            basins[r] += 1
            basinm += [(x,y)]
    else:
        c = (x,y) not in basinf
        if c:
            basinf += [(x,y)]
        r = basinf.index((x,y))
        if c: basins[r] = 1
    return r

size = input()
field = [map(int,raw_input().split()) for _ in range(size)]
print field
for y in range(size):
    for x in range(size):
        flow(x, y)
print
print ' '.join(map(str,sorted(basins.values(),reverse=1)))

JavaScript (ECMAScript 6) - 226 Characters
s=S.split(/\s/);n=s.shift(k=[]);u=k.a;t=s.map((v,i)=>[v,i,1]);t.slice().sort(X=(a,b)=>a[0]-b[0]).reverse().map(v=>{i=v[1];p=[v,i%n?t[i-1]:u,t[i-n],(i+1)%n?t[i+1]:u,t[+n+i]].sort(X)[0];p==v?k.push(v[2]):p[2]+=v[2]});k.join(' ')

Explanation
s=S.split(/\s/);                  // split S into an array using whitespace as the boundary.
n=s.shift();                      // remove the grid size from s and put it into n.
k=[];                             // an empty array to hold the position of the sinks.
u=k.a;                            // An undefined variable
t=s.map((v,i)=>[v,i,1]);          // map s to an array of:
                                  // - the elevation
                                  // - the position of this grid square
                                  // - the number of grid squares which have flowed into
                                  //      this grid square (initially 1).
X=(a,b)=>a[0]-b[0];               // A comparator function for sorting.
t.slice()                         // Take a copy of t
 .sort(X)                         // Then sort it by ascending elevation
 .reverse()                       // Reverse it to be sorted in descending order
 .map(v=>{                        // For each grid square (starting with highest elevation)
   i=v[1];                        // Get the position within the grid
   p=[v,i%n?t[i-1]:u,t[i-n],(i+1)%n?t[i+1]:u,t[+n+i]]
                                  // Create an array of the grid square and 4 adjacent
                                  //   squares (or undefined if off the edge of the grid)
     .sort(X)                     // Then sort by ascending elevation
     [0];                         // Then get the square with the lowest elevation.
   p==v                           // If the current grid square has the lowest elevation
     ?k.push(v[2])                // Then add the number of grid square which have
                                  //   flowed into it to k
     :p[2]+=v[2]});               // Else flow the current grid square into its lowest
                                  //   neighbour.
k.join(' ')                       // Output the sizes of the block with  space separation.

Previous Version - 286 Characters
s=S.split(/\s/);n=s.shift()*1;k=[];u=k[1];t=s.map((v,i)=>({v:v,p:i,o:[]}));for(i in t){t[p=[t[i],i%n?t[i-1]:u,t[i-n],(+i+1)%n?t[+i+1]:u,t[+i+n]].sort((a,b)=>(a.v-b.v))[0].p].o.push([i]);p==i&&k.push([i])}k.map(x=>{while(x[L="length"]<(x=[].concat(...x.map(y=>t[y].o)))[L]);return x[L]})

Assumes that the input is in a variable S;
Explanation
s=S.split(/\s/);                  // split S into an array using whitespace as the boundary.
n=s.shift()*1;                    // remove the grid size from s and put it into n.
k=[];                             // an empty array to hold the position of the sinks.
u=k[1];                           // Undefined
t=s.map((v,i)=>({v:v,p:i,o:[]})); // map s to an Object with attributes:
                                  // - v: the elevation
                                  // - p: the position of this grid square
                                  // - o: an array of positions of neighbours which
                                  //      flow into this grid square.
for(i in t){                      // for each grid square
  p=[t[i],i%n?t[i-1]:u,t[i-n],(+i+1)%n?t[+i+1]:u,t[+i+n]]
                                  // start with an array containing the objects
                                  //   representing that grid square and its 4 neighbours
                                  //   (or undefined for those neighbours which are
                                  //   outside the grid)
      .sort((a,b)=>(a.v-b.v))     // then sort that array in ascending order of elevation
      [0].p                       // then get the first array element (with lowest
                                  //   elevation) and get the position of that grid square.
  t[p].o.push([i]);               // Add the position of the current grid square to the
                                  //   array of neighbours which flow into the grid square
                                  //   we've just found.
  p==i&&k.push([i])               // Finally, if the two positions are identical then
                                  //   we've found a sink so add it to the array of sinks (k)
}
k.map(x=>{                        // For each sink start with an array, x, containing the
                                  //   position of the sink.
  while(x.length<(x=[].concat(...x.map(y=>t[y].o))).length);
                                  // Compare x to the concatenation of x with all the
                                  //   positions of grid squares which flow into squares
                                  //   in x and loop until it stops growing.
  return x.length                 // Then return the number of grid squares.
})

Test
S="3\n1 5 2\n2 4 7\n3 6 9";
s=S.split(/\s/);n=s.shift()*1;k=[];u=k[1];t=s.map((v,i)=>({v:v,p:i,o:[]}));for(i in t){t[p=[t[i],i%n?t[i-1]:u,t[i-n],(+i+1)%n?t[+i+1]:u,t[+i+n]].sort((a,b)=>(a.v-b.v))[0].p].o.push([i]);p==i&&k.push([i])}k.map(x=>{while(x[L="length"]<(x=[].concat(...x.map(y=>t[y].o)))[L]);return x[L]})

Outputs: [7, 2]
S="5\n1 0 2 5 8\n2 3 4 7 9\n3 5 7 8 9\n1 2 5 4 2\n3 3 5 2 1"
s=S.split(/\s/);n=s.shift()*1;k=[];u=k[1];t=s.map((v,i)=>({v:v,p:i,o:[]}));for(i in t){t[p=[t[i],i%n?t[i-1]:u,t[i-n],(+i+1)%n?t[+i+1]:u,t[+i+n]].sort((a,b)=>(a.v-b.v))[0].p].o.push([i]);p==i&&k.push([i])}k.map(x=>{while(x[L="length"]<(x=[].concat(...x.map(y=>t[y].o)))[L]);return x[L]})

Outputs: [11, 7, 7]
S="4\n0 2 1 3\n2 1 0 4\n3 3 3 3\n5 5 2 1"
s=S.split(/\s/);n=s.shift()*1;k=[];u=k[1];t=s.map((v,i)=>({v:v,p:i,o:[]}));for(i in t){t[p=[t[i],i%n?t[i-1]:u,t[i-n],(+i+1)%n?t[+i+1]:u,t[+i+n]].sort((a,b)=>(a.v-b.v))[0].p].o.push([i]);p==i&&k.push([i])}k.map(x=>{while(x[L="length"]<(x=[].concat(...x.map(y=>t[y].o)))[L]);return x[L]})

Outputs: [5, 7, 4]

To my eye, the arrow (=>) function definitions are much clearer.

JavaScript (ES6) 190 203
Edit A little more ES6ish (1 year later...)
Define a function with input rows as a string, including newlines, return output as string with trailing blanks

F=l=>{[s,...m]=l.split(/\s+/);for(j=t=[];k=j<s*s;t[i]=-~t[i])for(i=j++;k;i+=k)k=r=0,[for(z of[-s,+s,i%s?-1:+s,(i+1)%s?1:+s])(q=m[z+i]-m[i])<r&&(k=z,r=q)];return t.sort((a,b)=>b-a).join(' ')}

// Less golfed
U=l=>{
      [s,...m] = l.split(/\s+/);
      for (j=t=[]; k=j<s*s; t[i]=-~t[i])
        for(i=j++; k; i+=k)
          k=r=0,
          [for(z of [-s,+s,i%s?-1:+s,(i+1)%s?1:+s]) (q=m[z+i]-m[i]) < r && (k=z,r=q)];
      return t.sort((a,b)=>b-a).join(' ')
    }

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

out(F('5\n1 0 2 5 8\n 2 3 4 7 9\n 3 5 7 8 9\n 1 2 5 4 2\n 3 3 5 2 1'))// "11 7 7"

out(F('4\n0 2 1 3\n2 1 0 4\n3 3 3 3\n5 5 2 1')) //"7 5 4"
<pre id=O></pre>

Perl 6, 419 404
Newlines added for clarity. You can safely remove them.
my \d=$*IN.lines[0];my @a=$*IN.lines.map(*.trim.split(" "));my @b;my $i=0;my $j=0;
for @a {for @$_ {my $c=$_;my $p=$i;my $q=$j;my &y={@a[$p+$_[0]][$q+$_[1]]//Inf};
loop {my @n=(0,1),(1,0);push @n,(-1,0) if $p;push @n,(0,-1) if $q;my \o=@n.sort(
&y)[0];my \h=y(o);last if h>$c;$c=h;$p+=o[0];$q+=o[1]};@b[$i][$j]=($p,$q);++$j};
$j=0;++$i};say join " ",bag(@b.map(*.flat).flat.map(~*)).values.sort: {$^b <=>$^a}

Old solution:
my \d=$*IN.lines[0];my @a=$*IN.lines.map(*.trim.split(" "));my @b;my $i=0;my $j=0;
for @a {for @$_ {
my $c=$_;my $p=$i;my $q=$j;
loop {my @n=(0,1),(1,0);@n.push: (-1,0) if $p;@n.push: (0,-1) if $q;
my \o=@n.sort({@a[$p+$_[0]][$q+$_[1]]//Inf})[0];
my \h=@a[$p+o[0]][$q+o[1]];last if h>$c;
$c=h;$p+=o[0];$q+=o[1]};@b[$i][$j]=($p,$q);++$j};$j=0;++$i};
say join " ",bag(@b.map(*.flat.flat).flat.map(~*)).values.sort: {$^b <=>$^a}

And yet I get beaten by Python and JavaScript solutions.

source: Stack Exchange

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

sort: votes


text:
Transform number into 7-segment display pattern
Given two arbitrary numbers A,B. Print number B as a Digital LED Pattern where A is the scale.
input:
1 2320451640799518

ouput:
 _  _  _  _     _     _     _  _  _  _  _     _
 _| _| _|| ||_||_   ||_ |_|| |  ||_||_||_   ||_|
|_  _||_ |_|  | _|  ||_|  ||_|  |  |  | _|  ||_|

input:
2 23

ouput:
 __  __
   |   |
 __| __|
|      |
|__  __|

Rules:

Use STDIN/STDOUT for input/output
Code with most up-votes wins. In case of Tie, shortest code will be accepted
Most up voted Answer will be accepted at 01/02/2014 (Accepted this answer with highest 12 votes)

Some related questions, for code stealing/inspiration: "Emulate a 7-segment display" and "LED Numbers and Letters".

@Wasi Thanks. I saw your edit which cleared it up for me.

Your 9 should have the underscore in the last line, to be like reversed 6.

@Tomas Thanks for the suggestion. But, we already have 13 answers so it will be unfair to change it further :-)

OK Wasi but I hope you don't mind that I used my prefered shape of 9 in my answer, as I like it more :-)

@Tomas You should post a correct answer first. After that you can append your preferred solution with it if you like.

OK. Don't like it but at least I saved one character on this change :)

Is it allowed to input the zoom number in command line option?

Even more closely related

Voting to close because there are no requirements for how scaling works, and many answers (including the accepted one) implement it completely different from the test cases.

Regardless of how the existing answers implement it, I'd be in favour of leaving this open/reopening it if and when you edit in a spec, detailing how to scale a given integer (and preferably also a clearer list of what each number looks like in 7-segment display, but that's not a massive issue)

Commodore 64 BASIC
PETSCII art rules :)

Output:

What happened to the digit 4? o.O

That's how I write number 4, but OK, I fixed that :)

Fascinating -- do you write it that way by hand too?  Is that common in Sweden, or wherever you originally hail from?

I would +100 if I could.

Python 3, 286 282 280
Yeah I golfed this one. Nice challenge!
n,x=input().split()
n=int(n)
l=lambda s:"".join(s)+"\n"
h=lambda s:s.replace(*"! ")*~-n+s.replace(*"!_")
print(l(" "+"_ "[c in"14"]*n+" "for c in x)+h(l("| "[c in"1237"]+n*"! "[c in"017"]+"| "[c in"56"]for c in x))+h(l(" |"[c in"0268"]+n*"! "[c in"1479"]+"| "[c=="2"]for c in x)))

Also, here's a Python 2 version weighing in at only 273 bytes!
Not updating this one any more with further golfed original source. This was created when the original source was 282 bytes (Python 3 version).
exec'eJxdzE0OgjAQhuE9pxhn1VIlFhHUpCdRQlAx1NShAYwsOLzgD4irSd758tC8UWX6SDTZe824V1mju+uQ0lQz4o5RJr0dzylUO0TvWmhiFRd4IHTy8VV5ZWZNesqYizNA7jJaSC4mOUHu2LJjwTAEFJgA7k+gCWWAsUuii5eihD5Bw0XOul07bPxVhLGgl/9OS9mXcbIOMf4BPgK037kfbv4EGUTbgVAK/SnwBAs+TpU='.decode('base64').decode('zip')

This may be cheating, so I'm adding it separately. Let me know whether this is considered valid or not.

Haskell (389 chars)
The solution uses 7 arrays, one for each segment of the array, using the names from this image:

. The value a !! 4 will be the character that should be displayed at that a position for the number 4.
The values are multiplied by the scale where appropriate (using r and rp for replication), and finally printed out.
The code
a="_ __ _____"
b="|||||  |||"
c="|| |||||||"
d="_ __ __ _ "
e="| |   | | "
f="|   ||| ||"
g="  _____ __"
r=replicate
cm=concatMap
s=(' ':).(++" ")
dd w n=[[t n],rp$m f b n,[o g f b n],rp$m e c n,[o d e c n]] where
 rp=r$w-1
 t=cm(s.r w.(a!!))
 q f s x y=cm(\n->x!!n:r w(f s n)++[y!!n])
 o=q(!!)
 m=q const ' '
go a=unlines$concat$dd(read$a!!0)$map(read.(:[]))$a!!1
main=interact$go.words

Example usage
echo '1 2320451640799518' | runhaskell ./digit_led.hs
 _  _  _  _     _     _     _  _  _  _  _     _
 _| _| _|| ||_||_   ||_ |_|| |  ||_||_||_   ||_|
|_  _||_ |_|  | _|  ||_|  ||_|  |  |  | _|  ||_|

C, 249 226 chars
Golfed solution in C:
int x,y,g,s,q;main(){char*c,i[99];for(scanf("%d %98s",&s,i);y<2*s+1;++y,puts(""))for(c=i;*c;++c)for(x=0;x<s+2;++x)q=(y+s-1)/s*3+(x+s-1)/s,g=(x%(s+1))*(y%s)?7:q<3?~q%2*7:q-2,putchar("_|_||_| "["zG<lMfvH~N"[*c-48]+1>>g&1?g:7]);}

With added whitespace:
int x, y, g, s, q;

main() {
  char *c, i[99];
  for (scanf("%d %98s", &s, i); y < 2 * s + 1; ++y, puts(""))
    for (c = i; *c; ++c)
      for (x = 0; x < s + 2; ++x)
        q = (y + s - 1) / s * 3 + (x + s - 1) / s,
        g = (x % (s + 1)) * (y % s)
          ? 7
          : q < 3
            ? ~q % 2 * 7
            : q - 2,
        putchar("_|_||_| "["zG<lMfvH~N"[*c - 48] + 1 >> g & 1 ? g : 7]);
}

Notes:

At most 99 digits are printed
Behavior is undefined if the input is not well formed (e.g. contains non-digits, or scale is < 1)
Should be legal C89 code

I will provide an explanation of how it works, should anyone care.

From what I read around this page on what is "OK in C" you do not need to include #include <stdio.h> (As it will compile without it.) You can also put one int in main(), e.g. main(x), shaving off 1 byte – though it is not valid signature, and put scanf inside for: for(scanf("%d %98s", &s, &i); …) shaving of one more. – Have a look here.

@Sukminder These are very helpful hints, thanks! I removed the #include, moved the scanf inside the for, removed the unnecessary & in &i, and put the int variables in global scope to exploit the static 0 initialization. The code should now still be legal C89, but I didn't check thoroughly. I believe putting one int in main is not legal, so I left that out.

Giving up standard compliance can help a lot. For example, you can omit int for global variables. Also %98s can be %s (for longer strings you fail anyway, does it matter in what way?)

Good! I used "kind of" similar philosophy, but simpler - 187 chars in PERL

Ruby 2.0
Quick and (not so) naive ruby implementation.
V,H = ' |',' _'
l = gets.split
s = l[0].to_i
o = Array.new 1+s*2, ''
l[1].each_char {|c|
  m = "{H=mNgwI\x7FO"[c.to_i].ord
  o[0] += " #{H[m[0]]*s} "
  o[s] += "#{V[m[1]]}#{H[m[2]]*s}#{V[m[3]]}"
  o[s*2] += "#{V[m[4]]}#{H[m[5]]*s}#{V[m[6]]}"
}
(s-1).times { |i|
  o[i+1] = o[s].gsub '_', ' '
  o[s+i+1] = o[s*2].gsub '_', ' '
}
o.each {|r| puts r}

Quick explanation:
I first declare the strings representing on and off digits for horizontal and vertical bars.
Then I read scale and the digits.
I then declare an array of the necessary size to store enough lines for the given scale.
The weird string is actually a mapping of 7-bits values representing which LEDs to switch on for each digit.
Next, for each digit, I fill the output array from top to bottom, taking into account horizontal scaling.
The final loop is to fill the rows that only have vertical bars, which can just be generated from the middle and bottom rows by removing horizontal bars.
Finally, I print the output array !

Can you explain what's going on here?

Python 2.6 with no imports. I'd say that the attractiveness of this solution is the use of templates. Unfortunately I think that's why I had such a hard time compacting it.
def numbers(scale, number):

    def single(yay, wall, digit):
        walls = ('1110111', '0010010', '1011101', '1011011',
                 '0111010', '1101011', '1101111',
                 '1010010', '1111111',
                 '1111010')
        return yay if int(walls[digit][wall]) else ' '

    def expand_one(char, digit):
        characters = '_||_||_'
        translated = single(characters[char], char, digit)
        if char % 3:
            return translated
        return translated * scale

    def expand_template(template, digit):
        out = ''
        for c in template:
            if c == '.':
                out += ' ' * scale
            elif c == ' ':
                out += c
            else:
                out += expand_one(int(c), digit)
        return out

    def repeated_expand_template(template, n):
        print ''.join(expand_template(template, int(d)) for d in n)

    repeated_expand_template(' 0 ', number)
    for _ in range(scale - 1):
        repeated_expand_template('1.2', number)
    repeated_expand_template('132', number)
    for _ in range(scale - 1):
        repeated_expand_template('4.5', number)
    repeated_expand_template('465', number)

scale, number = raw_input().split()
numbers(int(scale), number)

And a bit shorter (308 characters):
s,n=raw_input().split();s=int(s)
for e in('0 0 ','11.2','0132','14.5','0465'):print '\n'.join(''.join(''.join(([' ','_||_||_'[int(c)]][int(bin(1098931065668123279354)[7*int(d)+int(c)+2])]*(s,1,1)[int(c)%3])if ord(c)>46 else c for c in e[1:].replace('.',' '*s))for d in n) for _ in range((1,s-1)[int(e[0])]))

Fyi, the top of the digits are supposed to be '_' (underscores), and no spaces between digits. I was confused at first haha

(Edit: This solution is now invalid because the semantics of the 銻 instruction has changed. I didn’t realise that I’d already made use of the instruction when I changed it. You can, however, fix ths program by simply changing it to the newer instruction 壹.)
Sclipting — 85 characters
겠合글坼銻標⓷가殲갰復묽땸민뫝뜵깉걈밂⓶各가⓵겐上⓷감嚙긇밌⓶掘⓶감嚙눖밂⓶掘⓷合⓶감嚙긇밌⓶掘⓷合⓸⓸替❶終⓶丟終❶눠替눐終①貶復⓶⓷終丟併눐替글①復終눠替뇰①復終⓶丟

①
Input:
1 1024856359701

Output:
    _  _     _  _  _  _  _  _  _  _
  || | _||_||_||_ |_  _||_ |_|  || |  |
  ||_||_   ||_| _||_| _| _|  |  ||_|  |

②
Input:
2 47474747

Output:
     __      __      __      __
|  |   ||  |   ||  |   ||  |   |
|__|   ||__|   ||__|   ||__|   |
   |   |   |   |   |   |   |   |
   |   |   |   |   |   |   |   |

Can you fix the program? Leaving the whole post stroke out is quite ugly.

I could of course change the 銻 to 壹, but that would make this entry cheating because 壹 was invented after this challenge was posted.

I don't think it is that much of a problem. I doesn't make your program any shorter anyway.

No, but it would violate an important rule of this community.

No longer violates a rule :P

C# (480 443 chars)
namespace System{using z=String;using w=Console;class P{static void Main(){var t=w.ReadLine().Split(' ');var s=int.Parse(t[0]);z b="17",d=b+23,e=b+3459,f="56",g=e+2680;Action<z,z,z,int>q=(l,m,r,n)=>{for(int i=1;i<n;i++){foreach(var c in t[1]){h(c,l);for(int j=0;j<s;j++)h(c,m,"_");h(c,r);}w.Write("\n");}};q(g,"14",g,2);q(d,g,f,s);q(d,b+0,f,2);q(e,g,"2",s);q(e,b+49,"2",2);}static void h(char x,z m,z y="|"){w.Write(m.Contains(""+x)?" ":y);}}}

Extended version:
using System;
using System.Linq;

namespace Segments
{
    internal class Program
    {
        static void Main()
        {
            var scale = int.Parse(Console.ReadLine());
            var input = Console.ReadLine();

            PrintLine(input, "", "14", "", 2);
            PrintLine(input,"1237", "", "56", scale);
            PrintLine(input,"1237", "170", "56", 2);
            PrintLine(input,"134579", "", "2", scale);
            PrintLine(input,"134579", "147", "2", 2);
        }

        static void PrintLine(string input, string leftMatch, string middleMatch, string rightMatch, int scale)
        {
            for (int i = 1; i < scale; i++)
            {
                foreach (var c in input)
                {
                    PrintDigitLine(c, leftMatch, '|', 1);
                    PrintDigitLine(c, middleMatch, "_", scale);
                    PrintDigitLine(c, rightMatch, '|', 1);
                }
                Console.Write("\n");
            }
        }

        private static void PrintDigitLine(char digit, string match, char charToPrint, int)
        {
            for (int i = 0; i < n; i++) Console.Write(match.Contains(digit) || match == "" ? ' ' : charToPrint);
        }
    }
}

My idea was to split the task up into 5 horizontal lines, which in turn are split up in a left, right and middle part for each character.

Maybe I copied it wrong, but I tried running this on ideone and it gave an error. http://ideone.com/gQ6LH7

probably my fault, let me see

@C0deH4cker I took the input in two separate ReadLines. This one works: http://ideone.com/4jTxeu

Ah gotcha! Looks nice!

Btw, the '9' shouldn't have the bottom part according to OP's format. I had to add a character to mine to handle this lol

@C0deH4cker I made a version that takes the input as specified, and drops the bottom part of the 9. The input takes as many chars, the 9 costs 1 extra.

You have a redundant ; in there (480); you can write Action<z,z,z,int>q=(l,m,r,n)=>{...}; (470); you can make the first parameter of h a char and do the ""+ inside h (467); and finally, you can declare and re-use z d="134579",b="1237" (465). That’s the smallest I could make it so far

Move the for-loop from inside h to only around the second call to h and remove the fourth parameter (455)

Use a using w=Console; (453)

Declare another e=d+2680 and use it in place of the ""s; then you can remove ||m=="" (451)

Declare another a="17" and then all the other concatenations can use integers. I now have: z a="17",b=a+32,d=a+3459,e=d+2680;q(e,"14",e,2);q(b,e,"56",s);q(b,a+0,"56",2);q(d,e,"2",s);q(d,a+49,"2",2); — (450)

Slight error there: Zeros now render wrongly because you wrote e+0268, which causes the 0 to be missing. You need to put the 0 in any other place than the beginning of the literal.

Looking at the other C# answer, it turns out that declaring the namespace isn’t worth it. If you remove that, remove the using System and add System. in front of Console, String and Action, you get down to 445.

I fixed the error and put the whole thing in the System namespace -> 443

I guess there are very shorter solutions, but since this is not code-golf I'm quite satisfied!
This PHP script will take two numbers a, b from STDIN and echo b in LED format, at a size.
fscanf(STDIN, "%d %d", $a, $b); //Didn't test this line, but it should be ok.
$space=str_repeat(" ", $a);

$top = $topLeft = $topRight = $mid = $botLeft = $botRight = $bot = array();
for ($i=0; $i<count($b); $i++) {
    $top[$i] = $topLeft[$i] = $topRight[$i] = $mid[$i] = $botLeft[$i] = $botRight[$i] = $bot[$i] = true;
switch ($b[$i]) {
    case 0:
        $mid[$i] = false;
    break;
    case 1:
        $top[$i] = $topLeft[$i] = $mid[$i] = $botLeft[$i] = $bot[$i] = false;
        break;
    case 2:
        $topLeft[$i] = $botRight[$i] = false;
        break;
    case 3:
        $topLeft[$i] = $botLeft[$i] = false;
        break;
    case 4:
        $top[$i] = $botLeft[$i] = $bot[$i] = false;
        break;
    case 5:
        $topRight[$i] = $botLeft[$i] = false;
        break;
    case 6:
        $topRight[$i] = false;
        break;
    case 7:
        $topLeft[$i] = $mid[$i] = $botLeft[$i] = $bot[$i] = false;
        break;
    case 9:
        $botLeft[$i] = false;
        break;
    }
}

horizontal($top);
vertical($topLeft, $topRight);
horizontal($mid);
vertical($botLeft, $botRight);
horizontal($bot);

function horizontal($position) {
    global $a, $b, $space;
    for ($i=0;$i<count($b);$i++) {
        if ($position[$i])
            echo " ".str_repeat("-", $a)." ";
        else
            echo " ".$space." ";
    }
    echo "
";
}

function vertical($positionLeft, $positionRight) {
    global $a, $b, $space;
    for ($j=0;$j<$a;$j++) {
        for ($i=0;$i<count($b);$i++) {
            if ($positionLeft[$i]) {
                echo "|".$space;
                if ($positionRight[$i])
                    echo "|;";
                else
                    echo " ";
            }
            else {
                echo " ".$space;
                if ($positionRight[$i])
                    echo "|";
                else
                    echo " ";
            }
        }
        echo "
";
    }
}

EDIT: Looking at the previous output example, I wrongly supposed that space between digits should be as large as the a size. This has been fixed with the OP's declaration that no space is needed.

Actually, there shouldn't be any spaces between digits. The only reason it looks that way for the sample is the spaces are where the '|' would be on an 8 for example. Took me a while to figure out

Oh, you are right! Thank you :)

C#, 435 359 473 bytes
EDITS:

Removed redundant code.  Reduced byte size of comparisons.
Converted to a stand-alone application using standard in for input.

Here's the golfed code (with added line breaks and whitespace):
using C=System.Console;
class P{
    static void Main(){
        var a=C.ReadLine().Split(' ');
        D(int.Parse(a[0]),a[1]);
    }
    static void D(int r,string n){
        int i,j;
        string s="",v="|",w=" ",x=new string('_',r),y=new string(' ',r),z="\n";
        foreach(var c in n)s+=w+(F(0,c)?x:y)+w+w;
        for(j=1;j<6;j+=3)
            for(i=r;i-->0;){
                s+=z;
                foreach(var c in n)s+=(F(j,c)?v:w)+(i<1&&F(j+1,c)?x:y)+(F(j+2,c)?v:w)+w;
            }
        C.Write(s+z);
    }
    static bool F(int i,char c){
        return(new[]{1005,881,892,927,325,365,1019}[i]&1<<(int)c-48)>0;
    }
}

They are valid C# functions.  It was never stated that it should be a stand-alone program.  However, it doesn't use standard in.

@Timwi, edited to conform...

Well done!! I’ve golfed it some more and I got it down to 425 (characters; 432 bytes in UTF-8), making it shorter than the other C# answer. using System;using S=System.String;class P{static void Main(){Action<S[]>D=n=>{var r=int.Parse(n[0]);Func<int,int,bool>F=(i,c)=>("ϭͱͼΟŅŭϻ"[i]&1<<c-48)>0;S s="",v="|",w=" ",x=new S('_',r),y=new S(' ',r);foreach(var c in n[1])s+=w+(F(0,c)?x:y)+w+w;for(int j=1;j<6;j+=3)for(int i=r;i-->0;){s+="\n";foreach(var c in n[1])s+=(F(j,c)?v:w)+(i<1&&F(j+1,c)?x:y)+(F(j+2,c)?v:w)+w;}Console.Write(s);};D(Console.ReadLine().Split(' '));}}

Using the other C# answer’s idea of putting everything in the System namespace takes it down to 423

C (561 492 bytes)
Author is frmar. He sent me his answer last week (he has not yet created his account).
492 bytes but a bit more obfuscated:
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#define C(x) ((_[*n-'0'])>>s)&m&x
#define P putchar
unsigned _[]={476,144,372,436,184,428,492,148,508,188};
void p(int a,char*n,unsigned m,int s)
{for(;isdigit(*n);++n){P(C(1)?'|':' ');
for(int i=0;i<a;++i)P(C(4)?'_':' ');
P(C(2)?'|':' ');}
P('\n');}
void l(int a,char*b){p(a,b,7,0);int i=1;
for(;i<a;++i)p(a,b,3,3);p(a,b,7,3);i=1;
for(;i1?atoi(v[1]):1,c>2?v[2]:"0123456789");}

Previous version using 561 bytes:
#include<stdio.h>
#include<ctype.h>
#define C(x) ((((*n-'0')[_])>>s)&m&x)
const unsigned _[]={476,144,372,436,184,428,492,148,508,188};
void p(int a,const char*n,unsigned m,int s)
{
 for(;isdigit(*n);++n) {
  putchar(C(1)?'|':' ');
  const char c=C(4)?'_':' ';
  for(int i=0;i<a;++i) putchar(c);
  putchar(C(2)?'|':' ');
 }
 putchar('\n');
}
void l(int a,const char*b)
{
 p(a,b,7,0);
 for(int i=1;i<a;++i)p(a,b,3,3);p(a,b,7,3);
 for(int i=1;i<a;++i)p(a,b,3,6);p(a,b,7,6);
}
#include<stdlib.h>
int main(int c,char**v){l(c>1?atoi(v[1]):1,c>2?v[2]:"0123456789");}

Original version from frmar (623 bytes):
#include<stdio.h>
#include<ctype.h>
const unsigned int _[]={476,144,372,436,184,428,492,148,508,188};
void p(int a,const char*n,unsigned int m,int s)
{
  for(;isdigit(*n);++n) {
#define C(x) ((((*n-'0')[_])>>s)&m&x)
    putchar(C(1)?'|':' ');
    const char c=C(4)?'_':' ';
    for(int i=0;i<a;++i) putchar(c);
    putchar(C(2)?'|':' ');
  }
  putchar('\n');
}
void print_as_led(int a,const char*b)
{
  p(a,b,7,0);
  for(int i=1;i<a;++i)p(a,b,3,3);p(a,b,7,3);
  for(int i=1;i<a;++i)p(a,b,3,6);p(a,b,7,6);
}
#include<stdlib.h>
int main(int argc,char**argv){print_as_led(argc>1?atoi(argv[1]):1,argc>2?argv[2]:"0123456789");}

Compilation:
$ gcc -std=c99 -Wall print_as_led.c

Examples using default 0123456789 number but different sizes:
$ ./a.out
 _     _  _     _  _  _  _  _
| |  | _| _||_||_ |_   ||_||_|
|_|  ||_  _|  | _||_|  ||_|  |

$ ./a.out 2
 __      __  __      __  __  __  __  __
|  |   |   |   ||  ||   |      ||  ||  |
|  |   | __| __||__||__ |__    ||__||__|
|  |   ||      |   |   ||  |   ||  |   |
|__|   ||__  __|   | __||__|   ||__|   |

$ ./a.out 3
 ___       ___  ___       ___  ___  ___  ___  ___
|   |    |    |    ||   ||    |        ||   ||   |
|   |    |    |    ||   ||    |        ||   ||   |
|   |    | ___| ___||___||___ |___     ||___||___|
|   |    ||        |    |    ||   |    ||   |    |
|   |    ||        |    |    ||   |    ||   |    |
|___|    ||___  ___|    | ___||___|    ||___|    |

Other examples:
$ ./a.out 1 42
    _
|_| _|
  ||_

$ ./a.out 2 42
     __
|  |   |
|__| __|
   ||
   ||__

$ ./a.out 3 42
      ___
|   |    |
|   |    |
|___| ___|
    ||
    ||
    ||___

Larger sizes:
$ ./a.out 4 42
       ____
|    |     |
|    |     |
|    |     |
|____| ____|
     ||
     ||
     ||
     ||____
$ ./a.out 5 42
        _____
|     |      |
|     |      |
|     |      |
|     |      |
|_____| _____|
      ||
      ||
      ||
      ||
      ||_____

Perl + FIGlet + BRA*: 54 characters
while(<>){($n,$x)=split;print(`figlet -f 7seg$n $x`);}

I figured this would be quite easy to do with FIGlet, but there didn't appear to be any suitable fonts for this purpose. So I made some :-)

7seg1.flf
7seg2.flf
7seg3.flf

Here's how it looks on the terminal:
$ perl ./led.pl
1 234
 _  _
 _| _||_|
|_  _|  |
2 345
 __      __
   ||  ||
 __||__||__
   |   |   |
 __|   | __|
3 456
      ___  ___
|   ||    |
|   ||    |
|___||___ |___
    |    ||   |
    |    ||   |
    | ___||___|

*BRA: blatant rule abuse

Don't get why there is a downvote for that. Nice trick with fonts!

I was not downvoting, but I would understand that using a program instead of actually making the program is cheating.

PERL,   261 244 187   166 chars
Little bit of bitwise encoding philosophy rulez :-)
($n,$a)=split/ /;sub c{$_=$a;y/0-9/Gl+%<UWm7=/;s/./(substr"   _ _|_| |_  |",2*ord($&)>>$_[0]&$_[1],3)=~s|.\K.|$&x$n|er/ge;print y/_/ /r x($n-1).$_}c 0,2;c 4,14;c 1,14

Code with whitespace added:
($n,$a)=split/ /;

sub c{
$_=$a;
y/0-9/Gl+%<UWm7=/;
s/./(substr"   _ _|_| |_  |",2*ord($&)>>$_[0]&$_[1],3)=~s|.\K.|$&x$n|er/ge;
print y/_/ /r x($n-1).$_
}

c 0,2;
c 4,14;
c 1,14

Perl has to be invoked with -n:
$ perl -n digitize.zoom.pl
1 12304597
     _   _   _       _   _   _
  |  _|  _| | | |_| |_  |_|   |
  | |_   _| |_|   |  _|   |   |
2 0784
 __   __   __
|  |    | |  | |  |
|  |    | |__| |__|
|  |    | |  |    |
|__|    | |__|    |
3 789
 ___   ___   ___
    | |   | |   |
    | |   | |   |
    | |___| |___|
    | |   |     |
    | |   |     |
    | |___|     |

Notes:

Everything about how digits are displayed is encoded in the string Gl+%<UWm7= :-) One character corresponds to one digit, encoded are 3 positions of 3 consecutive characters within the "   _ _|_| |_  |" string.
Numbers are constructed in 3 lines, line by line. Each of the 3 lines corresponds to one call to sub-routine c, which also accomplishes vertical zooming for second and third line.
Horizontal zooming is done at the end of sub-routine c.

My sed program cannot zoom, but it looks a lot nicer, doesn't it? :-)
s/./\0 /g
h
s/[14]/   /g
s/[2305-9]/ _ /g
p
g
s/[17]/  |/g
s/[23]/ _|/g
s/[489]/|_|/g
s/[56]/|_ /g
s/0/| |/g
p
g
s/[147]/  |/g
s/2/|_ /g
s/[359]/ _|/g
s/[680]/|_|/g

Pretty much the idea my  PERL script uses, but in PERL it's a lot uglier. Note that for my sed program I prefered to use 9 which has the underscore in the last line, to be like reversed 6.

I was wondering if you could explain how the scaling works, I am trying to implement my own version in Perl. But can't seem to get the vertical and horizontal scaling right.

C#, 386 382 364 chars / 374 bytes (UTF-8) and (lots? of) room for improvement...
using System.Linq;using C=System.Console;class P{static void Main(string[] args){var s=C.ReadLine();for(int l=0;l<5;l++){for(int j=0;j<s.Length;j++)C.Write(string.Join("",Enumerable.Range(0,3).Select(i=>{var x=l*3+i;return((x&1)>0?((((System.Text.Encoding.Unicode.GetBytes("⑷浝欮╻潿")[(byte)s[j]-48]>>x/2)&1)==1)?(x-1%3>0?"|":"-"):" "):" ");}))+" ");C.WriteLine();}}}

EDIT
Crap... I missed the "scale" part
I'll give it another shot if I get around to it..

Yeah, the scale part makes it scary.

J - 147 95 characters
Added required scaling:
1!:2&2,./(([1 s 0 s=:1 :(':';'y#"(2-m)~(m{$y)$1,x'))"2(3 :'(y{(5 3$&,0&,.)"1@#:l)}d')@"."0@":)/".]1!:1]1[l=:>:a.i.'v#\Z9jnQ~z'[d=:' ',:5 3$' - | |'

Annotated version:
NB. Digit array (2 x 5 x 3) first is blank, second is filled.
d=:' ',:5 3$' - | |'
NB. Bits to selector (taking into account that all "usefull" bits are separated with 0 bits, looking at the 5 x 3 grid)
bts =: 5 3 $&, (0&,.)
NB. list of character bits.
l=: 119 36 93 91 58 107 111 82 127 123
NB. golfing using ascii range
l=: >:a.i.'v#\Z9jnQ~z'

NB. scaling function
NB. scaling in 1 direction involves inserting copies of the middle segments:
NB. from y, copy the middle segments, 1 x 1 x 1 for rank 2 and 1 x 1 for rank 1
NB. Usage: scale (rank s) segment
s=: 1 : (':';'y#"(2-m)~(m{$y)$1,x')
NB. scale first along columns, then along rows, apply only to rank 2 (planes)
b=:([1 s 0 s)"2

NB. Get one number by using amend with a selection array (0 is blank, 1 is filled)
NB. get the y'th plane from the array of 10 x 5 x 3 selector bits, use those to index d with.
g=: 3 : '(y { (bts"1 #: l)) } d'
NB. from right to left: read stdin, convert number string to numbers,
NB. use the left for scaling, and split the right in digits,then apply g,
NB. then paste them together so the numbers appear next to each other.
NB. Put this result on stdout
1!:2&2,./(b g@"."0@":)/".]1!:1]

Example:
1 0123456789
 -     -  -     -  -  -  -  -
| ||    |  || ||  |    || || |
       -  -  -  -  -     -  -
| ||  |    |  |  || |  || |  |
 -     -  -     -  -     -  -

2 123
     --  --
|      |   |
|      |   |
     --  --
|   |      |
|   |      |
     --  --

How does this answer the question?

You are absolutely right ... I'll fix it

Your example is incorrect. Watch the question.

Ruby,126 ASCII characters
->n,x{(n*2).downto(0){|i|x.bytes{|c|z='u"ik:[]b}{'[c-48].ord+2>>i/n*3&7
print' |'[z/2%2],(z%2>i%n ??_:' ')*n,' |'[z/4]}
puts}}

Each digit is encoded as a bitmap in thirds thus, with each third represented by an octal digit.
|_| 8^2 (left and right never used! only the 1's bit used!)
|_| 8^1 (4*right+2*left+1*bottom)
|_| 8^0 (4*right+2*left+1*bottom)

As all digits have either the 64's bit or 32's bit set, the range is 044 octal to 177 octal. Unfortunately 177 is the nonprintable DEL character, so the magic string contains the numbers 2 below the required bitmap code, and we have to add 2 back on in the function.
Ungolfed in test program
f=->n,x{
  (n*2).downto(0){|i|                               #1 top line, n middle lines, n bottom lines
    x.bytes{|c|                                     #iterate through bytes
      z='u"ik:[]b}{'[c-48].ord+2>>i/n*3&7           #find octal code for current 1/3 digit
      print' |'[z/2%2],(z%2>i%n ??_:' ')*n,' |'[z/4]#print left,right and bottom
    }                                               #z%2>i%n only true on bottom row of 3rd where i%n=0 (print _'s) and octal code has 1's bit set
    puts                                            #print a newline to finish line
  }
}

n=gets.to_i  #size
x=gets.chop  #number taken in string form
f[n,x]

Output
C:\Users\steve>ruby 7seg.txt
4
0123456789
 ____        ____  ____        ____  ____  ____  ____  ____
|    |     |     |     ||    ||     |          ||    ||    |
|    |     |     |     ||    ||     |          ||    ||    |
|    |     |     |     ||    ||     |          ||    ||    |
|    |     | ____| ____||____||____ |____      ||____||____|
|    |     ||          |     |     ||    |     ||    |     |
|    |     ||          |     |     ||    |     ||    |     |
|    |     ||          |     |     ||    |     ||    |     |
|____|     ||____  ____|     | ____||____|     ||____| ____|

Perl 6, 284 241 237
my (\a,\n)=split " ",slurp.trim;my @p=n.comb;sub g(\b,\c){for @p {my $h=:36(b);$h+>=3*$_;for ^3 {my \e=$_==1;print " |_".substr($h%2&&(c+!e)&&1+e,1)x a**e;$h+>=1}};say ""};for <52N98I 0 HMTVAD 1 AZRXEV 1> ->\s,\q{g(s,0)for 2..a*q;g(s,1)}

Previous solutions:
my (\a,\n)=slurp.trim.split: " ";my @p=n.comb;sub g(\b,\c){for @p {my $h=b;$h+>=3*$_;for ^3 {my \e=$_==1;print " |_".substr($h%2&&(c+!e)&&1+e,1)x a**e;$h+>=1}};say ""};for 306775170,0,1066270117,1,664751335,1 ->\s,\q{g(s,0)for 2..a*q;g(s,1)}
my (\a,\n)=slurp.trim.split: " ";my @p=n.comb;my &f={print $^b.substr(3*$_,1)~($^c??$b.substr(3*$_+1,1)!!" ")x a~$b.substr(3*$_+2,1)for @p;say ""};for (" _     _  _    "~" _ "x 5,0,"| |  | _| _||_||_ |_   ||_||_|",1,"|_|  ||_  _|  | _||_|  ||_|  |",1) ->\s,\q{f(s,0)for 2..a*q;f(s,1)}

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳

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