text:
Huffman golfing
Write a filter that converts text from standard input to a representation of its Huffman tree on standard output.  In as few characters as possible.

you're free to consider newlines or not
output format is free, as long as it's some human-readable encoding of a tree.  s-exps, ascii-art and .png, all good.  RPN, .dot, I'll smile or frown, but that ought to be ok.  Program cores and/or raw pointers , no way.
no canonicalization needed; if the characters are at the right depth, that's good enough.

Sample possible output for "this is an example of a huffman tree" (from wikipedia):
(((e . (n . (o . u))) . (a . (t . m))) .
 (((i . (x . p)) . (h . s)) . (((r . l) . f) . #\space)))

I can't reproduce all possible valid outputs with human-readable representation combinations in here (the margin is a bit too thin), but what should check is which characters end up at which number of bits:

3 bits: a e [space]
4 bits: f h i m n s t
5 bits: l o p r u x

If [newline] is kept in, it appears appears in the "5 bits" level, but (any) two characters have to drop from there to 6 bits.

Why finishing that quick? There're only 2 answers so far.

No, didn't know that.  Is this written up somewhere?

I tried it out, but strange enough I could change the accepted answer, even if accepted for half a year. They possibly changed the rules.

@George Edison: Is this new? I remember this was different before.

GolfScript, 54 34 characters
:)1/.&.,({{),)@-,-}$(\(@[[\]]+}*~`

The script takes input from STDIN and prints the tree in the following form:
[[["a" "e"] [["t" "h"] ["i" "s"]]] [[["n" "m"] [["x" "p"] ["l" "o"]]] [[["u" "r"] "f"] " "]]]

You may try the code online.
Edit: In contrast to the longer version the character counts are not saved inside the tree but recalculated each time we need them.
Previous version with comments:
1/           # split text into chars
..&          # create string with unique chars

\`{          # for each char
  {1$=},       # filter the original string for this char
  ,            # count number of occurences
  ]            # build data entry [char count]
}+%          # end of for-each loop

.,           # count number of distinct chars
({           # decrement and loop that many times
  {1=}$        # sort list by count field
  (\(@         # take first two elements of sorted list
  +~           # flatten to stack
  [[           # start new entry
    @+           # add count values
    @@[\]        # join nodes into a new tree
    \            # swap count and tree
  ]]+          # close entry and add back to list
}*           # end of for-loop

~~           # flatten array
;            # discard count
`            # transform to readable

Ruby 1.9 - 160 138 113
f=Hash.new(0);$<.chars{|c|f[c]+=1}
f.all?{a,b,*f=f.sort_by(&:last);*a,i=a;*b,j=b;f<<[a,b,i+j];f[1]}
p f[0][0..-2]

Ungolfed:
f=STDIN.chars.inject(Hash.new(0)){ |f,c|
        f[c]+=1
        f
}
f=f.to_a.map &:reverse

while f.size > 1
        a, b, *f = f.sort_by &:first
        f = [[a[0]+b[0], a, b], *f]
end

p=->a{ a[1].is_a?(String) ? a[1] : [p[a[1]],p[a[2]]] }
p p[f[0]]

Output for this is an example of a huffman tree:

[[[[["l", "p"], ["r", "u"]], ["s", ["o", "x"]]], [["i", "n"], "e"]], [["a", ["h", "t"]], [["m", "f"], " "]]]

Perl, 148
With the p command-line option (counted in):
$b{$&}++while/./g;for(@_=map[$b{$_},$_],keys%b;$#
_;@_=([$_[0][0]+$_[1][0],"($_[0][1]$_[1][1])"],@_
[2..$#_])){@_=sort{$$a[0]<=>$$b[0]}@_}$_=$_[0][1]

Sample use:
$ <<< 'this is an example of a huffman tree' perl -pe '$b{$&}++while/./g;for(@_=map[$b{$_},$_],keys%b;$#_;@_=([$_[0][0]+$_[1][0],"($_[0][1]$_[1][1])"],@_[2..$#_])){@_=sort{$$a[0]<=>$$b[0]}@_}$_=$_[0][1]'
(((ae)(((rx)h)((po)(ul))))(((nm)(ti))((sf) )))

Ungolfed:
# count characters
$b{$&}++ while /./g;

for(
    # init: convert hash to array of [freq,tree] pairs
    @_ = map [$b{$_},$_], keys %b;
    # as long as there are more than one elements left
    $#_;
    # merge the two leftmost nodes
    @_ = ( [ $_[0][0]+$_[1][0], "($_[0][1]$_[1][1])" ], @_[2..$#_] )
)
{
    # keep array in ascending order at all times
    @_=sort{$$a[0]<=>$$b[0]}@_
}

# set up for print
$_=$_[0][1]

Haskell (233 228 223)
Not completely shure whether it is valid.
import List
data T=Char:=Int|N T T Int
s(x:=_)=show x
s(N a b _)='(':s a++s b++")"
g(_:=a)=a
g(N _ _ a)=a
i[a]=a
i(a:b:x)=t$N a b(g a+g b):x
t=i.sortBy((.g).(compare.g))
main=interact$s.t.map(\x->x!!0:=length x).group.sort

Outputs:

The quick, brown fox jumps over the lazy dog.

((((('k''l')('i''j'))(('p''q')('m''n')))((('a''b')('.''T'))(('f''g')('c''d'))))(((('z'('x''y'))'e')((('v''w')('s''t'))'o'))((('r''u')(('\n'',')'h'))' ')))

this is an example of a huffman tree

((('a''e')(('h''i')(('o''p')('\n''l'))))((('s''t')('m''n'))((('x'('r''u'))'f')' ')))
Output format is like in the question, but whithout whitespace and whithout , between the two arms. I assume it's human readable.

It's perfectly human-readable.  Assuming I'm human.

http://codepad.org/mjME3TGV - Program error: pattern match failure: i []

@George Edison: you need to provide an input string.  Or alternately: well, that [] is a perfectly sensible representation of the empty tree. O:-)

Adding support for the empty tree would make the whole beast much more complicated.

Python 3.1.2, 132 chars
i=input();n=[(i.count(c),c)for c in set(i)]
while n[1:]:n.sort(key=lambda x:x[0]);(a,b),(c,d),*e=n;n=e+[(a+c,(b,d))]
print(n[0][1])

It can't handle the empty string.


text:
Render "Digital Clock Style" Numbers
Write the shortest program which will take a string of numbers (of up to at least 20 length) as input, and display the output using the standard digital clock style numbers.  For instance for input 81, a solution with ascii output would give:
 _
|_|  |
|_|  |

Graphical output is also acceptable, if it helps.

any upper limit on "take a string of numbers as input" ?

Hmm, let's say one row on an 80 column screen (20) is good enough.

Related: http://stackoverflow.com/questions/1407422/code-golf-seven-segments

Also related: http://stackoverflow.com/q/3324301/code-golf-digital-clock

APL (Dyalog) (45)
{3 3⍴' _|'[1+⍵⊤⍨9⍴3]}¨⎕UCS'ા8धगɯે૙ࣃଏ૽'[1+⍎¨⍞]

The string, ા8धगɯે૙ࣃଏ૽, are the unicode characters 2750 56 2343 2327 623 2759 2777 2243 2831 2813 (however, you should be able to just copy and paste it). They encode the numbers. The program reads a line from the keyboard.
Explanation:

1+⍎¨⍞: read a line from the keyboard, parse each character as a digit, then add 1 to each number (APL arrays are 1-based by default).
⎕UCS'ા8धगɯે૙ࣃଏ૽'[...]: Select the characters belonging to the digits of the numbers you entered, and look up the Unicode values.
{...}¨: for each of these values, do:
1+⍵⊤⍨9⍴3: get the first 9 base-3 digits from the value as expressed in base-3, and add 1  (because the arrays ar 1-based).
' _|'[...]: select  a space, horizontal line, or vertical line depending on these digits
3 3⍴: format as a 3-by-3 box.

Funciton
Not really a language suitable for golfing... but regardless, I tried to keep the code size as small as I could — quite a different challenge than in “usual” languages. This is 1555 characters or 3110  bytes (if encoded as UTF-16; UTF-8 is larger).
Here’s a screenshot of the program running. It really works:

Since this looks ugly in StackExchange due to the extra line spacing, consider running the following code in your browser’s JavaScript console to fix that: $('pre').css('line-height',1)
     ╓─╖ ╔╗┌─╖   ┌─╖
     ║ɧ║ ║╟┤↔╟┐ ┌┤‼╟┐
     ╙┬╜ ╚╝╘═╝│ │╘╤╝│
╔═╗  ┌┴────┐  │┌┴╖ ┌┴╖
║0║ ┌┴─┐  ┌┴─┐└┤ɧ╟─┤·╟┐
╚╤╝┌┴╖┌┴╖┌┴╖┌┴╖╘╤╝ ╘╤╝│
┌┘┌┤·╟┤ɦ╟┤·╟┤?╟ │  ┌┴╖│
│ │╘╤╝╘╤╝╘╤╝╘╤╝ └──┤‼╟┘
│┌┴╖│ ┌┴╖┌┘╔═╧╗    ╘═╝
└┤?╟┘┌┤?╟┘┌╢10║    ┌─────────┐
 ╘╤╝ │╘╤╝┌┘╚══╝ ┌─┬┘╔══╗┌──╖┌┴╖ ╓─╖
  ┘  └───┘╔════╗│┌┴┐║21╟┤>>╟┤·╟┐║ɦ║
╔════════╗║1005╟┘└┬┘╚══╝╘═╤╝╘╤╝│╙┬╜        ┌─┐
║14073768║╚════╝ ┌┴╖ ┌─╖ ┌┴╖┌┴╖└─┴─────────┘┌┴╖
║7584800 ╟───────┤?╟─┤‼╟─┤ɧ╟┤·╟─────────────┤·╟┐╔═══════╗╔══╗
╚════════╝       ╘╤╝ ╘╤╝ ╘╤╝╘╤╝    ╔══╗┌─╖┌┐╘╤╝│║2097151║║21╟┐
 ╔═══════════════╗│   ┘   │  │     ║48╟┤−╟┤├─┤┌┘╚══╤════╝╚══╝│
 ║140737555464224╟┘  ┌────┘┌┬┘     ╚══╝╘╤╝└┘┌┘│╓─╖ │┌┐┌─╖┌─╖┌┴─╖
 ╚═══════════════╝   │ ┌───┘└─────────┐┌┴─╖ │┌┘║↔║ ├┤├┤‼╟┤↔╟┤>>║
┌────────────┐┌────┐┌┴╖│┌────────────┐├┤<<║ ││ ╙┬╜┌┘└┘╘╤╝╘═╝╘╤═╝
│   ╔══╗╔═══╗├┘╓─╖ └┤·╟┘│   ╔══╗╔═══╗├┘╘╤═╝ │└─┐└─┤╔═╗┌┴╖ ┌──┘
│   ║95║║892║│┌╢‡╟┐ ╘╤╝ │   ║95║║877║│ ┌┘╔══╧═╗│  │║0╟┤?╟┬┘
│   ╚═╤╝╚═╤═╝││╙─╜│  │  │   ╚═╤╝╚═╤═╝│╔╧╗║2097║│  │╚═╝╘╤╝│
│╔══╗┌┴╖┌┐│  ││┌─╖│ ┌┴╖ │╔══╗┌┴╖┌┐│  │║1║║151 ║│  └──────┘
│║32╟┤?╟┤├┤  │└┤‼╟┘┌┤‡║ │║32╟┤?╟┤├┤  │╚═╝╚════╝│
│╚══╝╘╤╝└┘└──┴┐╘╤╝ │╘╤╝ │╚╤═╝╘╤╝└┘└──┴┐      ┌─┘
│    ┌┴╖     ┌┴╖┌─╖│ │ ┌┴╖│  ┌┴╖     ┌┴╖ ┌─╖┌┴╖
│    │‼╟─────┤·╟┤‼╟┘ │┌┤·╟┘  │‼╟─────┤·╟─┤‼╟┤‡║
└┐┌┐ ╘╤╝     ╘╤╝╘╤╝  ││╘╤╝┌┐ ╘╤╝     ╘╤╝ ╘╤╝╘╤╝
 ├┤├┐┌┴╖╔══╗  └──┐┌┐ │└┐├─┤├┐┌┴╖╔══╗  ├──┐└  │
 │└┘└┤?╟╢32║╔═══╗├┤│┌┴╖││ └┘└┤?╟╢32║╔═╧═╗│┌┐┌┴╖╔══╗
╔╧══╗╘╤╝╚══╝║881╟┘│├┤?╟┘│    ╘╤╝╚══╝║325║└┤├┤?╟╢32║
║927║╔╧══╗  ╚═══╝ └┘╘╤╝╔╧═══╗╔╧══╗  ╚═══╝ └┘╘╤╝╚══╝
╚═══╝║124╟───────────┘ ║1019║║124╟───────────┘
     ╚═══╝             ╚════╝╚═══╝

It could probably be smaller if I hadn’t made a mistake due to which the output was back to front; I fixed that by adding an extra function to reverse the input. Otherwise I would probably have to rewrite all of it.
I also made another mistake (swapping the operands in two calls to ‼) which made it necessary to declare the extra ‡ function, but this one is so small it fits inside the main function and thus doesn’t add any characters!

Whoa, that looks cool. Not only the solution, the language too :-)

That is just awesome

J, 90, 78 68 chars
[ update: using unicode (1 byte) encoding:
,./(10 3 3$((90$3)#:256#.24x-~3&u:'%ė¨ÔW/~º»sy¡ăì<t÷²'){' _|'){~"./.Y
NB. utf characters are: 37 279 168 212 87 47 126 186 187 115 121 161 259 236 60 116 247 178

works as before: ]
,./(10 3 3$((90$3)#:1219424106940570763878862820444729939648410x){' _|'){~"./. '58321'
 _  _  _  _
|_ |_| _| _|  |
 _||_| _||_   |

The key is in the encoding of digits as base-3 integers. Zero, for example is:
:
 _
| |
|_|

or ' _ | ||_|', which becomes 0102022123 = 2750.

I could save 10 characters if J had high precision base-36 numbers. Any suggestions anyone?

I'm using binary now. I wonder if trinary would save me some strokes?

congratulations for having the 1000th post on codegolf.SE! (http://codegolf.stackexchange.com/q/1000)

2+ years late but thanks :)

wxpython, many characters
import wx, wx.gizmos as g

class T(wx.Frame):
 def __init__(_):
  wx.Frame.__init__(_, None, size = (800, 60))
  l = g.LEDNumberCtrl(_, -1)
  l.Value = raw_input()

class M(wx.App):
 def OnInit(_):
  T().Show()
  return 1

M().MainLoop()

Test
echo -n 81 | python codegolf-997-wx.py

ps: not a serious entry, but looks like graphical output is also acceptable, so I just gave it a try :-)

+1 Glad to see this :).

Way too many of you. :P

Golfscript - 66 chars
"placeholder text for userscript which counts chars             ";

xxd: (use xxd -r to revert)
0000000: 332c 7b3a 533b 2e7b 3438 2d22 5e70 285d  3,{:S;.{48-"^p(]
0000010: 7025 d3c4 4ab1 7d4a b8dc 4469 ce41 2222  p%..J.}J..Di.A""
0000020: f303 227b 6261 7365 7d2f 3330 2f53 3d33  .."{base}/30/S=3
0000030: 2f3d 7b22 5f20 7c22 3d7d 257d 256e 407d  /={"_ |"=}%}%n@}
0000040: 2f3b                                     /;

This follows most of the other answers in that there are no spaces between numbers and trailing spaces are kept in. A space between numbers can easily be added with 1+ before {"_ |"=}%. Packed into a base 3 number, and then as base 243 into a string.

Fair enough.  I updated the question to not bother with the unnecessary space between numbers.

I think the "placeholder..." thing is a bit confusing.

Mathematica 205 209 198 179
i = IntegerDigits; t = Thread; r = Rule;
z@n_ := Row@i@n /. t[r[Range[0, 9], Grid[Partition[ReplacePart[Characters@" _ |_||_|",
t[r[#, ""]]], 3], Spacings -> 0] &
/@ (i /@ {5, 24578, 49, 47, 278, 67, 6, 4578, , 78})]]

Usage
z@1234567890

JavaScript (145)
148 145
Since JavaScript doesn’t really have standard input/output, this is written as a function that takes a string and returns the output as a string.
function r(n){for(i=o="",b=" |_\n|",L=n.length;i<3*L;)o+=b[(c="ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L])>>(i++/L|0)*3)&1]+b[c&2]+b[c&4]+b[i%L?0:3];return o}

Spaced out:
function r(n)
{
    for (i = o = "", b = " |_\n|", L = n.length;   i < 3*L;   )
        o += b [ (c = "ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L]) >> (i++/L|0)*3) & 1 ] +
             b [ c&2 ] +
             b [ c&4 ] +
             b [ i%L ? 0 : 3 ];  // space or newline
    return o
}

Here’s how it works:

Every digit shape is encoded in a Unicode character consisting of 9 bits.
The first three bits are for the first row, etc.
In each group of three bits, the first specifies whether the first character is | or space, the second whether it’s _ or space, and the third again | or space.
These three bits are retrieved as c&1, c&2 and c&4, which are then used as indexes into the string b.
At each iteration, i%L is the “x-coordinate”, i.e. the digit within the input n
At each iteration, i/L is the “y-coordinate”, i.e. the row, but we need |0 to make it an integer
Finally, the spaces between the digits and the newlines between the lines are also retrieved by indexing into b, re-using the space character and the otherwise unused position 3 in that string! :)

Unicode! BAH! ... well, it is shorter than mine. +1

Ruby, 142
' _     _  _     _  _  _  _  _
| |  | _| _||_||_ |_   ||_||_|
|_|  ||_  _|  | _||_|  ||_| _|'.lines{|l|puts x.chars.map{|i|l[i.to_i*3,3]}*''}

expects input in the variable x. examples:
x = '321'
#  _  _
#  _| _|  |
#  _||_   |

x = '42'
#      _
#  |_| _|
#    ||_

ooooo. pretty! ...

python3.8.10 : 148 138 bytes
Old (148):
a=input()
N=0x375fa9176b3538d93ca41ea
for i in 0,3,6:print(''.join(' |'[N&x<<i>0]+' _'[N&x<<i+1>0]+' |'[N&x<<i+2>0]for x in[1<<9*int(x)for x in a]))

New (138):
a=input()
N=0x375fa9176b3538d93ca41ea
for i in -1,2,5:print(''.join(' |_|'[(N&x<<i+k>0)*k]for x in[1<<9*int(x)for x in a]for k in(1,2,3)))

try the code here

Welcome to code golf! Your answer is golfed, nice btw, but you require a tio.run link to go with your answer to prove it works thx! Link: https://tio.run/#python3

@DialFrost a TIO link is nice to have, so people can easily test it, but not at all required.

121 bytes

Golfscript - 97 chars
:*{32' _':$@'14'{?~!=}:&~32}%n*{:x' |':|\'1237'&$x'017'&|x'56'&}%n*{:x|\'134579'&$x'147'&|x'2'&}%

Use the backtick to save a char for all the numeric strings (how do I insert this character in the code format?)

@Nabb: You can’t — StackExchange is crap like that...

D: 295 Characters
import std.stdio;void main(string[]a){string[3]o;foreach(c;a[1]){int n=cast(int)(c)-48;auto e=" ";o[0]~=n!=1&&n!=4?" _ ":"   ";o[1]~=!n||n>3&&n!=7?"|":e;o[1]~=n>1&&n!=7?"_":e;o[1]~=n<5||n>6?"|":e;o[2]~=!(n&1)&&n!=4?"|":e;o[2]~=!n||n>1&&n!=4&&n!=7?"_":e;o[2]~=n!=2?"|":e;}foreach(l;o)writeln(l);}

More Legibly:
import std.stdio;

void main(string[] a)
{
    string[3] o;

    foreach(c; a[1])
    {
        int n = cast(int)(c) - 48;
        auto e = " ";

        o[0] ~= n != 1 && n != 4 ? " _ " : "   ";

        o[1] ~= !n || n > 3 && n != 7 ? "|" : e;
        o[1] ~= n > 1 && n != 7 ? "_" : e;
        o[1] ~= n < 5 || n > 6 ? "|" : e;

        o[2] ~= !(n&1) && n != 4 ? "|" : e;
        o[2] ~= !n || n > 1 && n != 4 && n != 7 ? "_" : e;
        o[2] ~= n != 2 ? "|" : e;
    }

    foreach(l; o)
        writeln(l);
}

Wow, first D answer I've ever seen on this site!

Windows PowerShell, 127
$i="$input"[0..99]
'☺ ☺☺ ☺☺☺☺☺','♠☻♥♥♦♣♣☻♦♦','♦☻♣♥☻♥♦☻♦♥'|%{$c=$_
""+($i|%{('···0·_·0··|0·_|0|_|0|_·0|·|'-split0)[$c[$_-48]]})}

Since the strings contain some unpleasant-to-write characters, a hexdump for your convenience:
000: 24 69 3D 22 24 69 6E 70 │ 75 74 22 5B 30 2E 2E 39  $i="$input"[0..9
010: 39 5D 0A 27 01 00 01 01 │ 00 01 01 01 01 01 27 2C  9]◙'☺ ☺☺ ☺☺☺☺☺',
020: 27 06 02 03 03 04 05 05 │ 02 04 04 27 2C 27 04 02  '♠☻♥♥♦♣♣☻♦♦','♦☻
030: 05 03 02 03 04 02 04 03 │ 27 7C 25 7B 24 63 3D 24  ♣♥☻♥♦☻♦♥'|%{$c=$
040: 5F 0A 22 22 2B 28 24 69 │ 7C 25 7B 28 27 20 20 20  _◙""+($i|%{('
050: 30 20 5F 20 30 20 20 7C │ 30 20 5F 7C 30 7C 5F 7C  0 _ 0  |0 _|0|_|
060: 30 7C 5F 20 30 7C 20 7C │ 27 2D 73 70 6C 69 74 30  0|_ 0| |'-split0
070: 29 5B 24 63 5B 24 5F 2D │ 34 38 5D 5D 7D 29 7D     )[$c[$_-48]]})}

Look at all the smileys..

Java Solution: 585 570 Chars
I don't think I'll be attempting any more golfing in Java...
import java.util.*;
public class CG997{public static void main(String[]args){
short[][]lets=new short[][]{{0,1,3,2,0,4,2,1,4},{0,0,3,0,0,4,0,0,4},{0,1,3,0,1,
4,2,1,3},{0,1,3,0,1,4,0,1,4},{0,0,3,2,1,4,0,0,4},{0,1,3,2,1,3,0,1,4},{0,1,3,2,1
,3,2,1,4},{0,1,3,0,0,4,0,0,4},{0,1,3,2,1,4,2,1,4},{0,1,3,2,1,4,0,0,4}};
String[]syms=new String[]{" ","_","|","  ","| "};
String s=new Scanner(System.in).nextLine();
for(int o=0;o<3;o++){for(char c:s.toCharArray()){for(int i =0;i<3;i++)
System.out.print(syms[lets[Short.parseShort(c+"")][i+o*3]]);
}System.out.println();}}}

Your java version is way better/shorter than mine :)    btw!...  does 6 in digital clock representation has a cap (_) at top or not? I got confused after you output!

Upon checking the coffee maker behind me, the 6's should have a cap.  I'll update my solution.

Bash, 11 characters
toilet "$i"

Yes I know, I'm cheating.
You need to have toilet installed.

And have the default font set to one with 7 segment display numbers. figlet would also work.

gForth, 186 175 chars
New version:
: s query parse-word bounds s" D@DD@DDDDDb`ddfFF`fff`Fd`df`f`" bounds do cr 2dup do i c@ '0 - j + c@ 3 0 do dup 3 and s"  _|" drop + 1 type 4 / loop drop loop 10 +loop bye ; s

This actually bothers to exit (+3 chars) as well :). Here is the more readable version, it does some bit-packing to reduce the LUT size by 1/3, but the resulting code is more complex so it's not much of a savings:
: 7s query parse-word bounds
    s" D@DD@DDDDDb`ddfFF`fff`Fd`df`f`"
    bounds do
        cr
        2dup do
            i c@ '0 - j + c@
            3 0 do
                dup 3 and
                s"  _|" drop + 1 type
                4 / \ shorter than an rshift
            loop
            drop
        loop
    10 +loop bye ;
7s

Old version:
: s query parse-word bounds s"  _     _  _     _  _  _  _  _ | |  | _| _||_||_ |_   ||_||_||_|  ||_  _|  | _||_|  ||_|  |" bounds do cr 2dup do i c@ '0 - 3 * j + 3 type loop 30 +loop ; s

This leaves the stack unbalanced and doesn't bother to exit the interpreter. Here is a cleaner more readable version
: 7s query parse-word bounds
    s"  _     _  _     _  _  _  _  _ | |  | _| _||_||_ |_   ||_||_||_|  ||_  _|  | _||_|  ||_|  |"
    bounds do
        cr
        2dup do
            i c@ '0 - 3 * j + 3 type
        loop
    30 +loop 2drop bye ;
7s

Java 8, 280 274 bytes
interface M{static void main(String[]a){String x="",y=x,z=x;for(int c:a[0].getBytes()){c-=48;x+=" "+(c==4|c==1?" ":"_")+" ";y+=(c==7|c>0&c<4?" ":"|")+(c==7|c<2?" ":"_")+(c>4&c<7?" ":"|");z+=(c%2<1&c!=4?"|":" ")+(c%3==1?" ":"_")+(c==2?" ":"|");}System.out.print(x+"\n"+y+"\n"+z);}}

-6 bytes thanks to @ceilingcat.
Explanation:
Try it here.
interface M{                     // Class
  static void main(String[]a){   //  Mandatory main-method
    String x="",                 //   String for row 1, starting empty
           y=x,                  //   String for row 2, starting empty
           z=x;                  //   String for row 3, starting empty
    for(int c:a[0].getBytes()){  //   Loop over the bytes of the input
      c-=48;                     //    Convert the byte to integer
      x+=                        //    Append to row 1:
         c==4|c==1?              //     If the digit is a 1 or 4:
            "   "                //       Append three spaces
           :                     //      Else:
            " _ ";               //       Append a space + underscore + space instead
      y+=                        //    Append to row 2:
         (c==7|c>0&c<4?          //      If the digit is 1, 2, 3, or 7:
           " "                   //       Append a space
          :                      //      Else:
           "|")                  //       Append a pipe
         +(c==7|c<2?             //     +If the digit is 0, 1, or 7:
            " "                  //       Append a space
           :                     //      Else:
            "_")                 //       Append an underscore
         +(c>4&c<7?              //     +If the digit is 5 or 6:
            " "                  //       Append a space
           :                     //      Else:
            "|");                //       Append a pipe
      z+=                        //    Append to row 3:
         (c%2<1&c!=4?            //      If the digit is 0, 2, 6 or 8:
           "|"                   //       Append a pipe
          :                      //      Else:
           " ")                  //       Append a space
          +(c%3==1?              //     +If the digit is 1, 4, or 7:
             " "                 //       Append a space
            :                    //      Else:
             "_")                //       Append a pipe
          +(c==2?                //     +If the digit is 2:
             " "                 //       Append a space
            :                    //      Else:
             "|");               //       Append a pipe
    }                            //   End of loop
    System.out.print(x+"\n"+y+"\n"+z);
                                 //   Print the three rows
  }                              //  End of main-method
}                                // End of class

As function this would be 212 bytes instead.

JavaScript (V8), 118 115 bytes
-3 bytes: realised a cheaper way to loop through |_|
n=>[613550340,2132540234,1866373582].map(d=>n.replace(/./g,c=>(i=1<<c*3,g=s=>d&(i*=2)?s:' ')`|`+g`_`+g`|`)).join`
`

Try it online!
Takes input as a string of digits, uses three magic numbers which represent the state of each segment for each digit; every three bits is a digit.
Ungolfed and explained
n => [ // magic numbers
              //      9   8   7   6   5   4   3   2   1   0
  613550340,  // = 0b010_010_010_010_010_000_010_010_000_010_0
  2132540234, // = 0b111_111_100_011_011_111_110_110_100_101_0
  1866373582  // = 0b110_111_100_111_110_100_110_011_100_111_0
].map(d => n.replace(/./g,
  c => (
    i = 1 << c * 3, // initialise i to first bit of digit
    g = s => d & (i *= 2) ? s : ' ' // function to check bits
  )`|` + g`_` + g`|` // do function on each of '|_|'
)).join`

111

Java, 2,095
public class DigitalNumber {
    public static void main(String args[]){
        char[][] panel = new char[3][120]; //A 20 digit panel!
        int digXIndex = 0;int digYIndex = 0;
        for (int i=0;i<args[0].length(); i++){
            int dig=Integer.parseInt(""+args[0].charAt(i));
            panel[digXIndex][digYIndex]=32;
            digYIndex++;
            if (dig!=1 && dig!=4)
                panel[digXIndex][digYIndex]='_';
            else
                panel[digXIndex][digYIndex]=32;
            digYIndex++;
                panel[digXIndex][digYIndex]=32;
            digYIndex=3*i;
            digXIndex++;
            if (dig!=1 && dig!=2 && dig!=3 && dig!=7)
                panel[digXIndex][digYIndex]='|';
            else
                panel[digXIndex][digYIndex]=32;
            digYIndex++;
            if (dig!=1 && dig!=0 && dig!=7)
                panel[digXIndex][digYIndex]='_';
            else
                panel[digXIndex][digYIndex]=32;
            digYIndex++;
            if (dig!=6 && dig!=5)
                panel[digXIndex][digYIndex]='|';
            else
                panel[digXIndex][digYIndex]=32;
            digYIndex=3*i;
            digXIndex++;
            if (dig!=6 && dig!=8 && dig!=2 && dig!=0)
                panel[digXIndex][digYIndex]=32;
            else
                panel[digXIndex][digYIndex]='|';
            digYIndex++;
            if (dig!=7 && dig!=4 && dig!=1)
                panel[digXIndex][digYIndex]='_';
            else
                panel[digXIndex][digYIndex]=32;
            digYIndex++;
            if (dig!=2)
                panel[digXIndex][digYIndex]='|';
            else
                panel[digXIndex][digYIndex]=32;
            digXIndex=0;
            digYIndex+=(i*3)+1;
        }
        for (int i=0; i<3; i++){
            for (int j=0; j<120; j++)
                if (panel[i][j]!=0)
                System.out.print((char)(panel[i][j]));
                else
                    System.out.print("");
            System.out.println();
        }
    }
}

SAMPLE I/O
java DigitalNumber 98765432109876543210
     _  _  _  _  _     _  _     _  _  _  _  _  _     _  _     _
    |_||_|  ||_ |_ |_| _| _|  || ||_||_|  ||_ |_ |_| _| _|  || |
     _||_|  ||_| _|  | _||_   ||_| _||_|  ||_| _|  | _||_   ||_|

I should start hating java :)

Java is great for many things, but terse code is not one of them.

Well, this code isn't even golfed. It could be way shorter.

I golfed your code a bit ;)

C# 369 Characters
static void Main(string[] a){var b = new[] {123,72,61,109,78,103,119,73,127,111};var g = new[]{" _  ","|","_","| ","|","_","| "};a[0].ToCharArray().SelectMany((x,w)=>g.Select((y,i)=>new{s=((b[x-48]>>i&1)==1)?y:new String(' ',y.Length),j=i,v=w})).GroupBy(z=>(z.j+2)/3).ToList().ForEach(q=>Console.WriteLine(String.Join("", q.OrderBy(l=>l.v).Select(k=>k.s).ToArray())));}

I could easily cut a few characters out.  The point was more to abuse LINQ :)
More whitespace version:
static void Main(string[] a)
{
    var b = new[] {123, 72, 61, 109, 78, 103, 119, 73, 127, 111};
    var g = new[] { " _  ", "|", "_", "| ", "|", "_", "| " };
    a[0].ToCharArray().SelectMany(
        (x,w)=>g.Select(
           (y,i)=>new{s=((b[x-48]>>i&1)==1)?y:new String(' ',y.Length),j=i,v=w}))
            .GroupBy(z=>(z.j+2)/3).ToList().ForEach(
            q=>Console.WriteLine(
                String.Join("", q.OrderBy(l=>l.v).Select(k=>k.s).ToArray())));
}

First of all, you need a class declaration and usings (409). Then there is a some unnecessary whitespace that can be removed (402). The task states that whitespace between the digits shall be omitted (399).

Uh, thanks.  I edited the task because nobody was following the original whitespace rule.  Feel free to edit the answer if it offends you, because I just don't care.

g is used only once, so you can save 7 characters by inlining it.

Actually b is also used only once, so you can inline it too. Also, you can save a lot of characters if you change the integer array to "{H=mNgwI\x7fo", or even shorter if you change \x7f to the actual character #127 (which is unprintable, but permissible). The >> will still work because there is an implicit conversion from char to int.

Also, the .ToCharArray() and the .ToArray() are both redundant, you can just remove them :)

Python, 218 180 176
b=map(int,raw_input());a=map(int,bin(914290166014670372457936330)[2:]);c=' |_';p=lambda k:''.join(c[a[9*n+k]]+c[2*a[9*n+1+k]]+c[a[9*n+2+k]]for n in b)+'\n';print p(6)+p(0)+p(3)
With line breaks:
b=map(int,raw_input())
a=map(int,bin(914290166014670372457936330)[2:])
p=lambda k:''.join(' |'[a[9*n+k]]+' _'[a[9*n+1+k]]+' |'[a[9*n+2+k]]for n in b)+'\n'
print p(6)+p(0)+p(3)

PHP, 140 136 133 131 129 128 bytes
I could save 5 7 more with extended ascii: one each for "| _" and the linebreak, three for ~"z/]{4lno~|" (bitwise negation would turn everything to extended ascii characters = no special characters, and PHP doesn´t need quotes there), two for -1 (it´s only there to keep the map in standard ascii). But for readability and compatibility, I stay with standard ascii.
for(;""<$c=$argv[1][$i++];)for($n=753754680;$n>>=3;)$r[$p++%3].="| _"[ord(~"z/]{4lno~|"[$c])-1>>$n%8&1?:$n&2];echo join("
",$r);

the bitmap

Take LEDS _,|_|, |_| as bits -6-,024,135 (bit number &2 is 0 for vertical LEDs)
Create bitmaps for numbers 0..9: [123,48,94,124,53,109,111,112,127,125]
Decrease by 1 to make them all printable ascii codes -> "z/]{4lno~|"
negate -> ~"z/]{4lno~|" (allows ternary shorthand in character selection)

the template

use 7 for the spaces -> 767,024,135
regroup by columns instead of rows -> 701,623,745 (renders $p=0 obsolete)
reverse -> 547326107 (read the map from right to left; allows arithmetic looping)
append zero -> 5473261070 (allows to combine shift with test in loop head)
read octal, convert to decimal -> 753754680 (two bytes shorter: one digit and the prefix)

breakdown
for(;""<$c=$argv[1][$i++];) // loop through input characters
    for($n=753754680;$n>>=3;)   // loop through template
        $r[$p++%3].="| _"[          // append character to row $p%3:
            ord(~"z/]{4lno~|"[$c])-1// decode bitmap
                >>$n%8&1            // test bit $n%8 (always 1 for bit 7)
            ?                       // if set: 1 (space)
            :$n&2                   // else: 2 (underscore) for bits 2,3,6; 0 (pipe) else
        ];
echo join("\n",$r);         // print result

+16 bytes for hexadecimal: ord(~"z/]{4lno~|v.J=NF"[hexdec($c)])-1

Powershell, 114 bytes
param($a)6,3,0|%{$l=$_
-join($a|% t*y|%{('   0 _ 0 _|0|_ 0| |0  |0|_|'-split0)[(+('f-SR5Z^mvr'["$_"])-shr$l)%8]})}

Test script:
$f = {

param($a)6,3,0|%{$l=$_
-join($a|% t*y|%{('   0 _ 0 _|0|_ 0| |0  |0|_|'-split0)[(+('f-SR5Z^mvr'["$_"])-shr$l)%8]})}

}

&$f "1234567890"
&$f "81"

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

Main idea:
Each standard digital clock style number contains 3 lines. Moreover, the first line contains only 2 options. A total of 6 options. Therefore, 7 bits are enough to encode each digit.
line str=@('   ', ' _ ', ' _|', '|_ ', '| |', '  |', '|_|')

#    line str    binary       dec    ASCII
-    --------    ---------    ---    -----
0 -> 1
     4
     6        -> 1 100 110 -> 102 -> 'f'

1 -> 0
     5
     5        -> 0 101 101 ->  45 -> '-'

...

8 -> 1
     6
     6        -> 1 110 110 -> 118 -> 'v'

9 -> 1
     6
     2        -> 1 110 010 -> 114 -> 'r'

So, the string f-SR5Z^mvr encodes all segments for all standard digital clock style numbers.
Note: The order of the line str was specially selected so that all codes were in the interval 32..126.

Vyxal jṠ, 40 bytes
»*ż↵↲ṡŀ≬₍ṡfl₆ǎ8≠∇ƈH»`_ |`τ3/₀/ƛ£⁰ƛ¥nIi;ṅ

Try it Online!
A mess. Uses base-3 compression.
»...»                     # Compressed integer containing all digits
     `_ |`τ               # Decompress by custom base-3
           3/             # Divide into 3
             ₀/           # Divide each piece into 10
               ƛ          # Map this new list to...
                £         # Store to register
                 ⁰ƛ    ;  # Map this new input to...
                   ¥      # Push register
                    nIi   # Get correct value
                        ṅ # Join
                          # (Implicit) Join by newlines

Ocaml, 268
let t=function|'1'|'4'->"   "|_->" _ "let m=function|'0'->"| |"|'1'|'7'->"  |"|'2'|'3'->" _|"|_->"|_|"|'5'|'6'->"|_ "let b=function|'0'|'8'->"|_|"|'1'|'4'|'7'->"  |"|'2'->"|_ "|_->" _|"let f s=let g h=String.iter(fun c->print_string(h c))s;print_newline()ing t;g m;g b

Readable version
let t = function
  | '1'
  | '4' -> "   "
  | _ -> " _ "
let m = function
  | '0' -> "| |"
  | '1'
  | '7' -> "  |"
  | '2'
  | '3' -> " _|"
  | _ -> "|_|"
  | '5'
  | '6' -> "|_ "
let b = function
  | '0'
  | '8' -> "|_|"
  | '1'
  | '4'
  | '7' -> "  |"
  | '2' -> "|_ "
  | _ -> " _|"
let f s =
  let g h =
    String.iter (fun c -> print_string (h c)) s;
    print_newline () in
  g t;
  g m;
  g b

Ghostscript (270) (248) (214)
Edit: More substitutions. Removed space between digits.
Edit: Even more substitutions. Main loop now looks like what it does!
/F{forall}def[48<~HUp;::1ncBInp~>{1 index 1 add}F
pop/*{dup
2 idiv exch
2 mod
1 eq}/P{print}/#{( )P}/?{ifelse
P}/O{{( )}?}/|{*{(|)}O}/_{*{(_)}O}>>begin[[[[ARGUMENTS{{load
# _ #}F()=]2{{| _ |}F()=]}repeat]pop[[[[}F

Uses ghostscript's argument-processing feature: invoke with gs -dNODISPLAY -- digit.ps 012 345 6789.

Delphi || 453 (568 With format)
Not even close enough to win but it was fun to do ^.^
const asc: array[0..9] of array[0..2] of string = ((' _ ','| |','|_|'),('   ','  |','  |'),(' _ ',' _|','|_ '),(' _ ',' _|',' _|'),('   ','|_|','  |'),(' _ ','|_ ',' _|'),(' _ ','|_ ','|_|'),(' _ ','  |','  |'),(' _ ','|_|','|_|'),(' _ ','|_|',' _|'));var s,l:string;x,i:integer;begin Readln(s);s:=StringReplace(s,' ','',[rfReplaceAll]);for I := 0 to 2 do begin l:='';for x := 1 to length(s) do l := l + asc[StrToInt(s[x])][i];writeln(l);end;readln;end.

With format
const
asc: array[0..9] of array[0..2] of string = (
  (' _ ','| |','|_|'),
  ('   ','  |','  |'),
  (' _ ',' _|','|_ '),
  (' _ ',' _|',' _|'),
  ('   ','|_|','  |'),
  (' _ ','|_ ',' _|'),
  (' _ ','|_ ','|_|'),
  (' _ ','  |','  |'),
  (' _ ','|_|','|_|'),
  (' _ ','|_|',' _|'));
var
s,l:string;
x,i:integer;
begin
    Readln(s);
    s:=StringReplace(s,' ','',[rfReplaceAll]);
    for I := 0 to 2 do
    begin
      l:='';
      for x := 1 to length(s) do
        l := l + asc[StrToInt(s[x])][i];
      writeln(l);
    end;
    readln

end.

Perl 5 -F, 96 bytes
map{@m=/./g;say map{substr'    _  _||_ | |  ||_|',3*$m[$_],3}@F}1011011111,4522633566,6532526562

Try it online!
The string     _  _||_ | |  ||_| represents the possible "cross sections" of the digits (grabbed the idea from @mazzy's PowerShell solution).  The numbers in the list 1011011111,4522633566,6532526562 represent indices into that string for the first, second, and third line of each of the digits 0-9.  The index must be multiplied by 3 to get to the correct position.  This loops over each character input (stored in the @F array by the -F option on the command line), finds the correct index into the string for that input, and then outputs the result.
Old version: Perl 5 -n, 102 bytes
for$b(' a ',dbe,fcg){say s%.%'$b=~y/'.(b,abcdf,dg,df,acf,ef,e,bcdf,Z,f)[$&]."/ /r=~y/a-z/___|/r"%geer}

Try it online!
Considers the characters of the display to be named like this:
$$\begin{array}{|c|c|c|}
\hline
 & a &   \\ \hline
d &b & e \\ \hline
f & c & g \\ \hline
\end{array}$$
The code iterates over strings representing each line of that table (' a ',dbe,fcg).  On each of those, it changes the elements turned off into spaces. This information is in the list
(b,abcdf,dg,df,acf,ef,e,bcdf,z,f).  It uses the current element of the input (stored in $_ by the commandline switch and extracted by the pattern match into $&) to index into that list.  Finally, the letters a, b, and c are changed to underscores (_) and all other letters into pipes (|).

05AB1E, 36 bytes
•ʒïgÈ¨&Û≠∍›vâsŸ”_‡y•…| _ÅвJ3ôTäÅвø»

Outputs with additional single space between the output-digits. If this is not allowed, it'll be 1 byte longer by adding a J before the ».
Try it online.
Explanation:
•ʒïgÈ¨&Û≠∍›vâsŸ”_‡y•
          # Push compressed integer 5210925748351095970666976465591163407510385
 …| _     # Push string "| _"
     Åв   # Convert the integer to this custom base (basically convert it to
          # base-length - 3 in this case - and index each into the string)
       J  # Join this list of characters to a single string:
          #  " _ | ||_|     |  | _  _||_  _  _| _|   |_|  | _ |_  _| _ |_ |_| _   |  | _ |_||_| _ |_| _|"
3ô        # Split it into triplets
  Tä      # Split that into 10 equal-sized parts
    Åв    # Convert the (implicit) input-integer to this custom base
      ø   # Zip/transpose; swapping rows/columns
       »  # Join each inner list by spaces, and then each string by newlines
          # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why •ʒïgÈ¨&Û≠∍›vâsŸ”_‡y• is 5210925748351095970666976465591163407510385.
See this 05AB1E tip to understand how the ASCII-art string " _ | ||_|     |  | _  _||_  _  _| _|   |_|  | _ |_  _| _ |_ |_| _   |  | _ |_||_| _ |_| _|" is compressed.

Vyxal, 33 bytes
»@Ǐ+Ẇ₃e⋏UWṡ:≠7ẏŀz→=»`| _`τ₀/3/τ∩⁋

Ports the 05AB1E answer.
Try it Online!
How?
»@Ǐ+Ẇ₃e⋏UWṡ:≠7ẏŀz→=»`| _`τ₀/3/τ∩⁋
»@Ǐ+Ẇ₃e⋏UWṡ:≠7ẏŀz→=»              # Push compressed integer 5210925748351095970666976465591163407510385
                    `| _`         # Push string "| _"
                         τ        # Convert the integer to this custom base
                          ₀/      # Split into ten pieces
                            3/    # Split each into three pieces
                              τ   # For each string, convert the (implicit) input to this custom base
                               ∩  # Transpose
                                ⁋ # Join on newlines

Factor + lcd, 3 bytes
lcd

Try it online!

Perl (182 180)
#!perl -l
$_=<<7;
 _     _  _     _  _  _  _  _
| |  | _| _||_||_ |_   ||_||_|
|_|  ||_  _|  | _||_|  ||_| _|
7
@b=map{[/(...)/g]}split/\n/;@d=split//,<>;for$p(@b){print map$p->[$_],@d}

reads from STDIN.
$ perl 7segment.pl
1234567890987654321
    _  _     _  _  _  _  _  _  _  _  _  _  _     _  _     _
  | _| _||_||_ |_   ||_||_|| ||_||_|  ||_ |_ |_| _| _|  || |
  ||_  _|  | _||_|  ||_| _||_| _||_|  ||_| _|  | _||_   ||_|

Python, 227 chars
a="   ";b=" _ ";c="|_|";d="| |";e="|  ";f="  |";g="|_ ";h=" _|"
z=[[b,d,c],[a,f,f],[b,h,g],[b,h,h],[a,c,f],[b,g,h],[b,g,c],[b,f,f],[b,c,c],[b,c,h]]
x=map(int,raw_input())
for i in range(3):
 for j in x:
  print z[j][i],
 print

Simple and straightforward.

Python 3.4.3 - 1514 858 bytes
The temptation to solve this was too great not to sign up and answer =P
I'm a bit new to Python, so I formatted my program nice and neat (or at least I did). Improvements are greatly appreciated!
import sys;l1,l2,l3,l4,l5="";num=input()
for c in num:
    if c=="1":
        l1+=" oo  ";l2+="  o  ";l3+="  o  ";l4+="  o  ";l5+="oooo "
    if c=="2":
        l1+="oooo ";l2+="   o ";l3+="oooo ";l4+="o    ";l5+="oooo "
    if c=="3":
        l1+="oooo ";l2+="   o ";l3+=" ooo ";l4+="   o ";l5+="oooo "
    if c=="4":
        l1+="o  o ";l2+="o  o ";l3+="oooo ";l4+="   o ";l5+="   o "
    if c=="5":
        l1+="oooo ";l2+="o    ";l3+="oooo ";l4+="   o ";l5+="oooo "
    if c=="6":
        l1+="oooo ";l2+="o    ";l3+="oooo ";l4+="o  o ";l5+="oooo "
    if c=="7":
        l1+="oooo ";l2+="   o ";l3+="   o ";l4+="   o ";l5+="   o "
    if c=="8":
        l1+="oooo ";l2+="o  o ";l3+="oooo ";l4+="o  o ";l5+="oooo "
    if c=="9":
        l1+="oooo ";l2+="o  o ";l3+="oooo ";l4+="   o ";l5+="oooo "
    if c=="0":
        l1+="oooo ";l2+="o  o ";l3+="o  o ";l4+="o  o ";l5+="oooo "
print(l1+"\n"+l2+"\n"+l3+"\n"+l4+"\n"+l5)

Edit: Shortened variable names, used ; to shorten, only one space at end of output numbers, defined variables all at once.
New lines are 2 bytes (CRLF) and I used tabs instead of 4 spaces.

Welcome to Programming Puzzles & Code Golf! Since this is a code golf challenge, you'll want to make your code as short as possible. These tips maybe be helpful for golfing.

"I used tabs instead of 4 spaces" I'm confused. Why weren't you using tabs anyway? ;)

SmileBASIC, 216 bytes
?INPUT N$DIM A[14]COPY A,@A@A
DATA 1,0,0,1,3,1,1,3,0,4,3,4,1,6FOR D=0 TO LEN(N$)-1X=ASC("w$]m.k{%\o"[VAL(N$[D])])FOR I=0TO 6T=I*2IF X<<31THEN GBOX A[T]+D*5,A[T+1],A[T]+D*5+!(I MOD 3),A[T+1]+!!(I MOD 3)
X=X/2NEXT
NEXT

Using graphics instead of text, because it's probably shorter.
Explanation:
PRINT 'so the input and output don't overlap
INPUT NUMBER$ 'get number
DIM PTS[7*2] 'locations of segments
COPY PTS,@PTDATA 'copy data into array
@PTDATA
DATA 1,0,0,1,3,1,1,3,0,4,3,4,1,6 'stored as x,y,x,y,...
FOR DIGIT=0 TO LEN(NUMBER$)-1
 NUM=ASC("w$]m.k{%\o"[VAL(NUMBER$[DIGIT])]) 'get digit data. That data string doesn't have any non-ASCII characters, except \ which is 127 in SB.
 FOR I=0 TO 7-1 'draw each segment
  T=I*2 'position of point in array
  IF X AND 1 THEN GLINE PTS[T]+DIGIT*5,PTS[T+1],PTS[T]+DIGIT*5+!(I MOD 3),PTS[T+1]+!!(I MOD 3) 'draw segment. I MOD 3 determines whether it's horizontal or vertical.
  X=X>>1 'shift to next bit
 NEXT
NEXT

C++, 230 229 225 223 218 207 204 198 bytes
#import<iostream>
#define d for(auto
std::string v[3],t,g="|_| =2$0^262\'032;2$2?272";main(){std::cin>>t;d i:t)d j:{0,1,2})d k:{0,1,2})v[k]+=g[g[i*2-92+!k]>>j+k/2*3&1?j:3];d j:v)std::cout<<j<<'\n';}

Reads from stdin and output to stdout.
Explanation:
#import<iostream>                // string inside

std::string v[3], t, g="|_| "    // symbol on different horizontal position
      "=2$0^262\'032;2$2?272";   // space(0) or not(1) for each number and position
                                 // binary representation, last 6 bits is used
                                 // even positions are for row 1, 2; odds are for row 0

main() {
    std::cin>>t;                 // input
    for (auto i:t)               // for each character
        for (auto j:{0,1,2})     // for each horizontal position
            for (auto k:{0,1,2}) // for each vertical position
                v[k]+=g[         // use first four chars only
                    g[i*2-92     // i*2-96 is number*2, +4 to skip first four
                        +!k]     // row 0 uses another character
                    >>j+k/2*3    // (k==2?3:0)+j, the expected bit
                    &1           // extract the bit
                    ?j:3         // space or not space
                ];

    for (auto j:v) std::cout<<j<<'\n'; // output
}

JavaScript 137 133
r=(x,i=0,o='')=>{for(m of x){c="ŞHŦŬxļ>ňžŸ".charCodeAt(m)>>1<<i
for(j=3;j--;)o+=c&256>>j?'|_'[j%2]:' '}
return i<7?r(x,i+3,o+"\n"):o}

JavaScript (Node.js), 188 bytes
s=>[0,1,2].map(i=>s.replace(/./g,e=>[(t=(h,j='|',k=' ')=>(''+h).includes(e)?j:k)(2370+(b='5689'),' _ ','   '),t(104+b)+t(234+b,'_')+t(2347890),t(12680)+t(230+b,'_')+t(3704+b)][i])).join`
`

Try it online!
Not the shortest but uses a different approach.

C (gcc), 329 bytes
#define A 95:32
#define B '|':32
#define C s[0][k])?
#define I index(
#define P printf(
a;n;k;
main(c,s)char**s;{s++;a=strlen(*s);for(k=0;k<=a;k==a?k=0,n>4?k=2*a:n++:k++){!n&&P" %c  ",!I"14",C A);n==2&&P"%c%c%c ",!I"1237",C B,!I"170",C A,!I"56",C B);n==4&&P"%c%c%c ",!I"134579",C B,!I"147",C A,!I"2",C B);n&1?P"\n"),n++,k=-1:0;}}

Try it online!

274 bytes

Batch, 307 301 bytes
@echo off&!! 2>nul||cmd/q/v/c%0&&exit/b&set/px=&set n= _     _  _     _  _  _  _  _ 1 1  1 _1 _11_11_ 1_   11_11_11_1  11_  _1  1 _11_1  11_1 _1
for %%i in (0,3,6)do set t=&set j=0&call:l %%i&echo ␛[m!t:1=^|!
exit/b
:l
set/ad=3*!x:~%j%,1!+%~10,j+=1
set t=%t%!n:~%d%,3!&if .!x:~%j%! neq . goto:l
exit/b

␛ represents the nonprintable "" character and is used to make sure the first line is blank when the input only has 1s and 4s.

Perl, 145 characters
$i=<>;for$s(6,3,0){for($i=~/./g){$v=(175,9,158,155,57,179,183,137,191,187)[$_]>>$s;$o.=($v&4?'|':$").($v&2?'_':$").($v&1?'|':$")}$o.="
"}print$o

Ungolfed:
# Read STDIN
$i = <>;
# Amount to bit shift later
for $s (6,3,0)
{
  # For each character C from STDIN
  for ($i =~ /./g)
  {
    # Get the Cth array index, bit shifted right by $s
    $v = (175, 9, 158, 155, 57, 179, 183, 137, 191, 187)[$_]>>$s;
    # Concatenate each character if the bitwise masked value says it should be there
    $o .= ($v & 4 ? '|' : $") .
          ($v & 2 ? '_' : $") .
          ($v & 1 ? '|' : $");
  }
  # Concatenate a newline
  $o .= "
";
}
# Print the result
print $o;

source: Stack Exchange

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

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

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

sort: votes


text:
Day of the week of the next Feb 29th
Write a function which takes a date and returns the day of the week of the next February 29th after that date.

The input is a string in the ISO Extended format: YYYY-MM-DD (e.g. May 27th, 2010 would be "2010-05-27").
The output is a string which is the name of the day of the week (e.g. "Monday"). Capitalization doesn't matter, but do give the full name in English.
If the given date is February 29th, then return the day of the week of the next Feburary 29th.
Use the calculations for the Proleptic Gregorian Calendar (so, it uses the Gregorian leap year calculations for it's entire length). Don't worry about the Julian Calendar or when the switch from Julian to Gregorian occurred. Just assume Gregorian for everything.
The function should work for at least the range of "0001-01-01" - "2100-01-01".
Feel free to use whatever standard libraries your language of choice provides, but do not use 3rd party libraries unless you want to include that code as part of your solution.
Shortest code (fewest characters) wins.

Examples:

func("0001-01-01") -> "Sunday"
func("1899-12-03") -> "Monday"
func("1970-01-01") -> "Tuesday"
func("1999-07-06") -> "Tuesday"
func("2003-05-22") -> "Sunday"
func("2011-02-17") -> "Wednesday"
func("2100-01-01") -> "Friday"

(and no, you don't have to name the function func)
Hints:

Remember that years ending in 00 which aren't divisable by 400 aren't leap years.
January 1st, 0001 is a Monday.

Windows PowerShell, 65
Fairly straightforward.
filter f{for($d=date $_;($d+='1').day*$d.month-58){}$d.dayofweek}

As usual, we can shave off two bytes if we are willing to wait a long time till completion:
filter f{for($d=date $_;($d+=9).day*$d.month-58){}$d.dayofweek}

Test:
> '0001-01-01','1899-12-03','1970-01-01','1999-07-06','2003-05-22','2011-02-17','2100-01-01'|f
Sunday
Monday
Tuesday
Tuesday
Sunday
Wednesday
Friday

History:

2011-02-18 00:06 (65) First attempt.

What path is necessary for this to work? I have GnuWin date in my path, which is breaking it.

@Peter: It might clash with date. Just remove GNUWin32 from the PATH and it should work. Or change date to Get-Date (that kind of fallback behavior only works when no command is found – to check, just use gcm date). Anyway, I don't consider that a particular problem with this script as GNUWin32 is not part of any standard Windows installation.

The reason I asked was because I already tried using get-date and got the error message Method invocation failed because [System.Management.Automation.PSObject] doesn't contain a method named 'op_Addition'. Does it need PS2 or .Net 4 or something?

@Peter: I tried PowerShell v2. .NET 4 doesn't play into it since PowerShell is linked to the 2.0 runtime. In any case, there shouldn't be a PSObject coming back from Get-Date but a System.DateTime.

It's very weird. $d=Get-Date "0400-01-01"; $d++ gives an error message about ++ not being defined on DateTime. The same replacing ++ with +=1 or +="1" or +='1' gives the error message about PSObject. And just +"1" works.

It seems to be broken with PS1 and work with PS2, so maybe you should update the header.

Peter: Please just upgrade. PowerShell v2 was released 1½ years ago and is the current version. That scripts created recently won't necessarily run under old versions should be common sense.

Ruby 1.9, 85 characters
f=->a{require"date";d=Date.parse(a,0,0)+1;d+=1until d.day*d.month==58;d.strftime"%A"}

Straightforward solution. Call the function with f[args].

Edit: (87 -> 97) Fixed the 0001-01-01 testcase.
Edit 2: (97 -> 91) Date.parse allows specifying the date of the calendar reform as well.
Edit 3: (91 -> 87) Use a lambda instead of a function. Thanks Dogbert!
Edit 4: (87 -> 85) Remove unnecessary spaces. Thanks again, Dogbert!

Fails the testcase for "0001-01-01". Ruby's Date is too powerful, it takes Julian dates into account.

@Ventero What does def* do? Never seen it before.

@steenslag: Thanks, fixed that testcase. def* just defines a function called *. That way I don't need a space between def and the function name.

Couldn't you just define a lambda instead? a=->{...}

@Dogbert: Good call, thanks. Still used to Ruby 1.8, where a lambda has to be defined with f=lambda{|a|...}, which is longer than def* a;...;end.

Also, there's no need of any space after strftime.

And 1 until can be written as 1until.

T-SQL 166 185 Characters
CREATE PROCEDURE f29 (@d DATETIME) AS
DECLARE @i int
SET @i=YEAR(DATEADD(M,-2,@d)+3)
SET @i=@i+(4-@i%4)
IF @i%100=0 AND @i%400<>0 SET @i=@i+4
SELECT DATENAME(W,CAST(@i AS CHAR)+'-2-29')

I was already messing with T-SQL date functions, so I figured why not...
Original solution was incorrect...
Here's what I actually have to do to get that strategy to work:
CREATE PROCEDURE f29 (@d DATE) AS
DECLARE @i int
SET @i = YEAR(@d)
BEGIN TRY
SET @i=YEAR(DATEADD(D, 3, DATEADD(M,-2,@d)))
END TRY
BEGIN CATCH
END CATCH
SET @i=@i+(4-@i%4)
IF @i%100=0 AND @i%400<>0 SET @i=@i+4
SELECT DATENAME(W,CAST(@i AS CHAR)+'-2-29')

Given that I create an overflow subtracting 2 months from 0001-01-01 even if I do use the correct datatype I give up on creating something short and valid for this question.  O_o.  Trixsy questionzes.

I love seeing these T-SQL solutions. :)

C#, 176
Func<String,String>f=(d)=>{DateTime n;for(n=DateTime.Parse(d).AddDays(307);!(DateTime.IsLeapYear(n.Year));n=n.AddYears(1)){}return new DateTime(n.Year,2,29).ToString("dddd");};

You can save 8 bytes by using a normal function definition: string f(string d){...}

.ToString("dddd") prints the date in the current locale, though, not in English.

165 chars => string f(string d){var n=DateTime.Parse(d).AddDays(307);while(!(DateTime.IsLeapYear(n.Year)))n=n.AddYears(1);return(new DateTime(n.Year,2,29)).DayOfWeek.ToString();}

Further improved to 127 characters:
string f(string d){var n=DateTime.Parse(d).AddDays(1);return DateTime.IsLeapYear(n.Year)&&n.DayOfYear==60?n.DayOfWeek+"":f(n+"");}

Bash, 96 bytes
Thanks Peter... Highly golfed version, 96 bytes:
i=1;until [ `date -d"$1 $i days" +%m-%d` = "02-29" ];do((i++));done
date -d "${1} ${i} days" +%A

Old version, 229 bytes
#!/bin/bash
from=$1
i=1
while [ "$isFeb" = "" ] || [ "$is29" = "" ]
do
isFeb=`date -d "${from} ${i} days" | grep Feb`
is29=`date -d "${from} ${i} days" +%Y-%m-%d | grep "\-29"`
((i++))
done
((i--))
date -d "${from} ${i} days" +%A

SAMPLE I/O
:~/aman>./29Feb.sh 0001-01-01
Sunday
:~/aman>./29Feb.sh 1899-12-03
Monday
:~/aman>./29Feb.sh 1970-01-01
Tuesday

might have to set TZ if no default timezone is set, I learnt http://www.cyberciti.biz/faq/howto-linux-unix-change-setup-timezone-tz-variable/ while doing this on some online IDE

Are you going to golf this? ;p You can replace everything before the final line with i=0;d=;until [ \date -d"$1 $i days" +%m-%d` = "02-29" ];do((i++));done`

:-) as we already discussed bout my raw-ness over bash!...  For some reason, I don't fiddle much with bash.. they are so error prone!.. Thanks for ur suggestion.. updated!

Rawness with bash is no excuse for using four-letter variable names :P

yes sir, I got your point.

On second thoughts the hyphens in %m-%d and 02-29 can be removed. And so can d=; - that's from an earlier version which used $d, but this one doesn't.

Your old bytecount was 229 bytes. 229 -> 2 29 -> Feb 29? O_o

Perl, no date library: 160 159 155

sub f{($y,$m)=split/-/,@_[0],2;$y++if($m>'02-28');$y=($y+3)%400>>2;$y+=$y&&!($y%25);@r=(Tues,Wednes,Thurs,Fri,Satur,Sun,Mon);@r[(5*$y-($y/25&3))%7]."day";}

The real benefit of these date libraries is pushing off the length of the names of the days to someone else.
On the other hand, I think this is the only solution so far which works regardless of locale.

DATE and some BASHy glue (90)
The function:
f(){ while :;do $(date -d$1+1day +'set - %F %A 1%m%d');(($3==10229))&&break;done;echo $2;}

Testing:
$ for x in 0001-01-01 1899-12-03 1970-01-01 1999-07-06 2003-05-22 2011-02-17 2100-01-01 ; do f $x ; done
Sunday
Monday
Tuesday
Tuesday
Sunday
Wednesday
Friday

D: 175 Characters
S f(S)(S s){auto d=Date.fromISOExtString(s)+days(1);while(d.month!=Month.feb||d.day!=29)d+=days(1);return["Sun","Mon","Tues","Wednes","Thurs","Fri","Sat"][d.dayOfWeek]~"day";}

More Legibly:
S f(S)(S s)
{
    auto d = Date.fromISOExtString(s) + days(1);

    while(d.month != Month.feb || d.day != 29)
        d += days(1);

    return ["Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Sat"][d.dayOfWeek] ~ "day";
}

It's very easy to write in D, but it's definitely not going to win any code golfing contests. Still, outside of code golfing, I'd much rather have it easy to write and understand but long than have it terse but hard to write and understand.

Java 8 - 252 chars
Golfed:
import java.time.*;
import java.time.format.*;
public class S{public static void main(String[] a){LocalDate d=LocalDate.parse(a[0]).plusDays(1);while(d.getMonthValue()!=2||d.getDayOfMonth()!=29){d=d.plusDays(1);}System.out.println(d.getDayOfWeek());}}

Ungolfed:
import java.time.*;
import java.time.format.*;
public class S {
    public static void main(String[] a) {
        LocalDate d = LocalDate.parse(a[0]).plusDays(1);

        while(d.getMonthValue()!=2 || d.getDayOfMonth()!=29) {
            d = d.plusDays(1);
        }
        System.out.println(d.getDayOfWeek());
    }
}

I accept downvotes but can you please explain "the necro is real" and link to a FAQ that explains your point? I didn't think I would win but thought it would be interesting to see how Java could do, esp. given Java 8. I view code golf as having "weight classes" versus an outright competition. Java will rarely beat Ruby or Python outright.

The OP prohibits 3rd party libraries, so in 2011, a Java solution would be unpleasant, as one couldn't use the popular Joda Time library. However, Java 8 (released in March 2014) contains the JSR-310 DateTime library - http://en.wikipedia.org/wiki/Java_version_history#Java_SE_8_.28March_18.2C_2014.29 . My reason is that I thought Java 8 would be fun, and potentially interesting to some readers. (If you aren't one of those, fine: there is still a reason for the post.)

Rebol - 78
f: func[d][system/locale/days/(until[d: d + 1 d/day * d/month = 58]d/weekday)]

Ungolfed:
f: func [d] [
    system/locale/days/(
        until [
            d: d + 1
            d/day * d/month = 58
        ]
        d/weekday
    )
]

Example usage (in Rebol console):
>> f 0001-01-01
== "Sunday"

>> f 2100-01-01
== "Friday"

PHP, 104 bytes
function f($s){for($y=$s-(substr($s,5)<"02-29");!date(L,$t=strtotime(++$y."-2-1")););return date(l,$t);}

breakdown
for($y=$s-;                 // "-" casts the string to int; decrement year if ...
    (substr($s,5)<"02-29")  // ... date is before feb 29
    !date(L,                        // loop while incremented $y is no leap year
        $t=strtotime(++$y."-2-1")   // $t=feb 01 in that year (same weekday, but shorter)
    );
);
return date(l,$t);          // return weekday name of that timestamp

date(L): 1 for leap year, 0 else
date(l): full textual representation of the day of the week

GNU coreutils, 71 bytes
f(){
seq -f "$1 %gday" 2921|date -f- +'%m%d%A'|sed 's/0229//;t;d;:;q'
}

Linear search of the next 8 years (worst case, given 2096-02-29).  Sed finds and outputs the first line that matches 29th of February.
I was surprised to find that t;d;:;q was shorter than testing to see whether the digits remained (/[01]/d;q), despite being twice as many commands.
Tests
I added an extra line of tests for difficult corner cases:

for i in 0001-01-01.Sunday 1899-12-03.Monday \
    1970-01-01.Tuesday     1999-07-06.Tuesday \
    2003-05-22.Sunday      2011-02-17.Wednesday 2100-01-01.Friday \
    2000-02-28.Tuesday     2000-02-29.Sunday    2000-03-01.Sunday   2096-02-29.Friday
do
    printf "%s => %s (expected %s)\n" ${i%.*} $(f ${i%.*}) ${i#*.}
done

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


text:
Run-Length Encoding
Write a program uses run-length encoding to shorten a list of non-negative integers it has to read in.
You can assume the non-negative integers can fit in 32bit signed integers.
Input Format
The length, n, of the list on the first line.
On the second line, a space-separated list of integers representing the list of integers.
Output Format
A space separated list of integers. The first 2 integers represent the first run, the next 2 integers the second run and so on. For each pair of integers representing a run, the first integer represents the length of the run and the second represents the value of the integer in the run.
Sample Input
1.
5
1 1 3 2 2

2.
3
1 1 1

Sample Output
1.
2 1 1 3 2 2

2.
3 1

Limits
0<n<10000

Similar to golf.shinh.org/p.rb?Look+and+say and stackoverflow.com/questions/3908513/code-golf-morris-sequence

I think you should give a more tricky input, like 36/1 1 1 1 1 1 3 3 3 3 3 2 2 7 7 7 7 4 4 9 9 9 9 9 9 9 9 9 4 4 8 3 3 3 3 0, giving 6 1 5 3 2 2 4 7 2 4 9 9 2 4 1 8 4 3 1 0, to ensure correct output when there are several distinct sequences of same number.

sh - 33 29 28
read;echo`xargs -n1|uniq -c`

Usage:
$ cat input|sh 1015.sh
2 1 1 3 2 2

read skips the first line
xargs -n1 reads the reast and outputs each number on one line:
1
1
3
2
2

uniq -c filters adjacent matching lines (with the c switch it also prints the number of adjancent lines) :
2 1
1 3
2 2

echo sees those numbers as separate arguments and just prints them separated by a space:
2 1 1 3 2 2

WTF? How is that possible?

added explanations :-)

Very nice! (more chars)

You might be able to replace tail -n1| with a well-placed read;

And the tr can be replaced with an xargs.  read;echo\xargs -n1|uniq -c`` for 28 characters.

Perl, 46 56 68
$_=<>;s/(?{$a=1})(\d+)( \1(?{++$a}))*/$a $1/g

Run with the p command-line option (counted in code size):
$ perl -pe '$_=<>;s/(?{$a=1})(\d+)( \1(?{++$a}))*/$a $1/g'
5
1 1 3 2 2
  => 2 1 1 3 2 2
3
1 1 1
  => 3 1

Haskell (84 82)
import List
main=interact$unwords.(>>= \x->[show$length x,x!!0]).group.tail.words

Number of elements in the list is ignored.

Ruby - 57
$><<[*$<][-1].gsub(/(\d+)( \1)*/){"#{$&.split.size} "+$1}

Ungolfed:
length = STDIN.readline
input = STDIN.readline
print input.gsub(/(\d+)( \1)*/) { |match|
    "%d %s" % [ match.split.size, $1 ]
}

Python - 92
Here's my attempt, which is mostly what I had before I posted this question, though for some reason I used a literal space instead of a comma.
from itertools import*
r=raw_input
r()
for k,g in groupby(r().split()):print len(list(g)),k,

Scala - 136
def f(s:Seq[_]):String=if(s.isEmpty)""else{val(l,r)=s.span(s.head==);l.size+" "+s.head+" "+f(r)}
readLine
println(f(readLine split' '))

Beautiful! I attempted a recursive solution, but it was longer than my attempt above. And I totally missed the span function, the key here. I also didn't know you can do s.head==, a devious trick! Note: according to my editor, that's 135 chars (with LF), and 133 if we don't count the newlines (as others did).

@PhiLho I did a wc on it. You probably don't have a LF on the last line, and I did. I think LF must be counted, because they have actual meaning here -- I'd have to use ; if I made it a one-liner.

I agree we should count the LF as they are significant separators, but it looks like Python programs above doesn't count them, while they are as significant... You can get rid of the trailing LF for golf purpose (I too always have it!). And even use a plain 'print' as hamsterofdeath did. Note: I like your version because it is readable even in the golf state!

You can get this down to 126 by changing s.isEmpty -> s==Nil; s.head -> s(0); println -> print

also first readLine -> readInt

Scala - 101 characters
This is based on the regex solution. I didn't know this was valid regex in Java, actually! (Scala's regex is based on Java's)
print("(\\d+)( \\1)*".r.replaceAllIn({readLine;readLine},m=>(m.matched split' 'size)+" "+m.group(1)))

R, 33 bytes
Late answer....
cat(t(mapply(c,rle(scan()[-1]))))

Ungolfed
scan()[-1]      # read in from stdin [-1] drops first element
rle(..)         # perform run length encoding (return list with lengths and values)
mapply(c, list) # converts list to matrix
t()             # transposes this matrix so when extracted as a vector is length value ...
cat()           # writes to stdout (separated by space)

Python - 106 chars
Very simple conceptually, but some very expensive words weigh it down
from itertools import*
input()
print" ".join(`len(list(j))`+' '+i for i,j in groupby(raw_input().split()))

Wow. Haskell shorter than Python. That's nice.

You don't consider the first line of input.

@fR0DDY, ah well there goes another 8 strokes

C 101 Characters
#define p printf("%d %d ",c,l)
main(c,i,l){gets(&i);for(c=0;~scanf("%d",&i);l=i)i!=l&&c?p,c=1:c++;p;}

Python 100 Characters
c=l=0
input()
for i in raw_input().split():
 if i!=l and c:print c,l,;c=1
 else:c=c+1
 l=i
print c,l

Python - 110 chars
import re;R=raw_input;R()
print" ".join(`len(x[0].split())`+' '+x[1]for x in re.findall(r"((\d+)( \2)*)",R()))

Why do you add two Python answers, where the other one is better then this one?

@FUZxxl: 2 different methods of doing it.

Golfscript - 40 39
~-1](;(:<1\@{:b={)<}{' '<' '1b:<}if}/;;

you can leave the [ out, the ] will push one for you automatically

CJam, 11 bytes
l;l~]e`e_S*

CJam interpreter online (test case provided by this comment).
Explanation:
l;l~]e`e_S*
l           Get input line
 ;          Remove ToS
  l         Get input line
   ~        Evaluate code
    ]       Wrap the stack in an array (from [-mark)
     e`     Run-length encode
       e_   Flatten
         S  Space (' ')
          * Join

Retina, 23 bytes
Thanks to @MartinEnder who helped me save 23 (!!) bytes and helped me understand some new features to (hopefully) produce better examples of Retina code in the future!
A1`
(\d+)( \1|)*
$#2 $1

Explanation
The first line is AntiGrep with a limit of 1 to remove the first line.  Then we match any integer followed by either a space and the same integer or nothing which handles our count correctly, so we can just replace with the number of matches of group 2 ($#2), and the original integer ($1).
Try it online!

I think you can remove the third and fourth lines if you change the fifth to (\d+)( \1)*.

@ETHproductions and the last two... How did I not see that :| Thanks!

...except now it fails on inputs containing 111, 1111, etc. :|

@ETHproductions Hmmm, but only if they\re the last numbers?! Sad. Ok, I'll delete and play. Thanks!

@ETHproductions Can't figure that out right now, so I've rolled back to your revision and I'll probably take a look after I've eaten. That'll probably help! :)

I believe this works: http://retina.tryitonline.net/#code=QTFgCihcZCspKCBcMXwpKgokIzIgJDE&input=MzYKMSAxIDEgMSAxIDEgMyAzIDMgMyAzIDIgMiA3IDcgNyA3IDQgNCA5IDkgOSA5IDkgOSA5IDkgOSA0IDQgOCAzIDMgMyAzIDA While this is a lot shorter it just resulted from a few incremental improvements to your idea: use antigrep to discard the first line, move the space into the second group to avoid append and deleting a space at the end, then originally I incremented group 2 with an additional (?<2>) to avoid the unary, but adding an empty alternative also does the trick.

Amazing... halfed the by count. I knew I didn't like the duplication of the unary. Using the empty group handling that is clever. AntiGrep makes sense, I didn't get it when I first read the docs, but that's probably just concentration lapse. Amazing updates for sure. Thank you for sharing. I'll try and retain this information!

Scala - 141 chars
a purely functional scala solution. i am using 2 hacks here (beginning and end markers = "a", have to cut them off at the end :()
"a" is the program parameter
the full working code is
package hstar.randomstuff

import tools.nsc.io.File

/**
 * Developed with pleasure :)

 * User: HoD

 * Date: 28.07.11

 * Time: 19:37

 */

object RLEEncoder {
  def main(a: Array[String]) {
   print(((0,"","")/:(File(a(0)).lines.toSeq(1).split(' '):+"a"))((a,c)=>if(a._2!=c)(0,c,a._3+' '+a._1+' '+a._2)else(a._1+1,c,a._3))._3.drop(4))
  }
}

the actual logic is
print(((0,"","")/:(File(a(0)).lines.toSeq(1).split(' '):+"a"))((a,c)=>if(a._2!=c)(0,c,a._3+' '+a._1+' '+a._2)else(a._1+1,c,a._3))._3.drop(4))

Cool! Don't forget to mention it is Scala. And prepend the title with # to get it big.

Mmm, I had to change File(a(0)) to tools.nsc.io.File(args(0)), so that's 157 chars. And it counts one less than needed.

Note: with the changes I suggest, your line works as a Scala script: scala RLE.scala input.txt; the off-by-one error is fixed with (1,c,a._3 instead of (0,c,a._3

Add a line of equal signs (=) underneath the title to turn it into a title.

@PhiLho If it's a one-liner script, one can use scala -e '...' to run it! :-)

Scala - 247 196
(+ 4 separators)
Being a beginner at Scala, I found the challenge interesting for a functional approach, but I fear I haven't took a concise approach. I guess a seasoned Scala coder will make a one liner... Particularly if I missed a useful collection method!
Anyway, here is the golfed version, even if it is out of competition:
readLine;val n=(readLine+" z").split(' ')
def g(v:String)={var a=1
(n:String)=>{if(n==v){a+=1;Nil}else List(a,v)}}
var p=g(n.head)
print(n.tail.flatMap{n=>val r=p(n);if(r!=Nil)p=g(n);r}.mkString(" "))

I feel the newlines should be counted (as spaces) as here they are mandatory separators. But well, the Python scripts above doesn't count them (while they are mandatory too), so I hadn't either...
The uncompressed version, with comments for my own benefit:
// Read the stdin, skipping the first line, returning the second one
// cat input.txt | scala RLE.scala
readLine // Thanks Daniel!
val line = readLine

// Add an arbitrary symbol that is dropped in the process... (trigger last sequence processing)
val numbers = (line + " z").split(' ')
println(numbers mkString " ")

/** Returns a closure to process the given value in the sequence to come */
def getSeq(value: String) =
{
  var acc = 1
  // Make a closure over value and acc
  (n: String) =>
  {
    if (n == value)
    {
      acc += 1
      Nil
    }
    else // Different value, return the cumulation so far
    {
      List(acc, value)
    }
  }
}

var process = getSeq(numbers.head) // Initial closure
/** Processes the numbers in the sequence. */
def accumulate(n: String) =
{
  val p = process(n)
  if (p != Nil) // We got a result
  {
    process = getSeq(n) // We need a fresh function over the new sequence that starts
  }
  p
}

println(numbers.tail.flatMap(accumulate).mkString(" "))

Feels clumsy with ugly hacks (the additional symbol, using head and tail...) but at least it works...
[EDIT] I used some of the tricks shown by Daniel Sobral to shorten a bit my code. I kept my original design/algorithm to be distinctive... :-)

How about:
Console.in.readLine;Console.in.readLine.split(" ").groupBy(f=>f).mapValues(_.size).map(e=>e._2+" "+e._1).mkString(" ")

Hmm, no that's of course no RLE what I've posted.

Yeah, I rejected groupBy as it returns a Map, while we need to keep order and to have identical "keys" within the result. The Console.in.readLine is useful, though.

JavaScript, 126 bytes
(x,j=0)=>(x=x.split` `).reduce((a,v,i)=>(v!=x[i-1]?(a[++j]=[]):a[j]).push(v)&&a,[]).reduce((a,v)=>a+v.length+" "+v[0]+" " ,"")

I'm guessing this can be reduced further, but I'm just happy it works.
First I split based on the space, then I convert the array from [1,1,1,2,2,3,3] to a series of array representing each run [[1,1,1],[2,2],[3,3]], then I reduce that again to produce the required output of "3 1 2 2 2 3".

Stacked, noncompeting, 34 bytes
([prompt]2*eval)behead flatrle out

Confirms strictly with the IO format. Try it here!
Or, we can use the builtin for 7 bytes: flatrle (or $flatrle).

Is this noncompeting?

@ZacharyT Ah, yes, of course.


text:
Random Sentence Generator
Write the shortest program you can in any language that reads a context-free grammar from and the number of sentences to produce from stdin, and generates that many random sentences from the grammar.
Input
Input will come in the following format:
n <START>
{"":["asdf","0","<C>","A", ...], "":["1<C>1","\<<T>>",...], ...}

n is the number of sentences to generate.  <START> is identifier of the starting nonterminal symbol.
The grammar is enclosed in the {} and is formatted as follows:

Rules are of the form "<S>":[productions].  <S> is the identifier of the nonterminal.

Rules are delimited with commas.
The right-hand side of a rule is a double-quoted string whose first and last characters are "<" and ">", respectively. The remaining character should be in [A-Z] (upper-case alpha).

productions is a comma-delimited list of double-quoted strings, representing productions.  All characters, including whitespace, in the rule are terminal symbols, except those that are enclosed in angle brackets ("<" and ">"), which are non-terminal symbols and will be the left-hand side of another rule.  An open angle bracket may be escaped, but there is no need to escape a close angle bracket.

Productions will not contain newlines or the newline escape sequence.

Output
You should print each generated sentence to stdout with a trailing newline.
Test Cases
5 sets of balanced parentheses:
5 <S>
{"<S>":["<S><S>", "(<S>)", ""]}

Example result:
(())()
()
()()()

(())(()())((((()))()()))

4 postfix arithmetic expressions (note whitespace within strings is significant, whitespace elsewhere is not):
4 <S>
{"<S>":["<N>", "<S> <S> <O>"], "<O>":["+","-","*","/"], "<N>":["<D><N>", "<D>"],
 "<D>":["1","2","3","4","5","6","7","8","9","0"]}

Example result:
1535235 76451 +
973812
312 734 99 3 + / *
1 1 1 1 1 + - * +

Can we have some sample input/output? (I know the exact output would be different in every case, but just for reference).

Good challenge, but I think the input format is more complicated than it could be.  Also, seeing as how the input format appears to be based primarily on JSON, wouldn't that give JavaScript and languages with built-in JSON parsing an unfair advantage.  Also, what does the backslash in \<<T>> indicate?

The backslash escapes the open bracket, so if T produced "1", that the pattern \<<T>> would produce \<1>, which would produce a <1> as the final output.  Yes, languages with JSON support would have a slight advantage, (though the escaped angle brackets should throw a wrench in that), but it at least levels the playing field for those languages not named "Perl".

The rules and examples don't seem to be entirely consistent on the amount of whitespace in the input.

@Peter: Whitespace outside of strings is insignificant; whitespace within strings is.

Maybe I’m misunderstanding something here, but it seems to me that the second example should say "<N>":["<D><N>", "<D>"] instead of just "<N>":["<D><N>"], as otherwise it never terminates...

@Timwi, You're absolutely right.  Fixed.

I felt like doing a little JavaScript.
Also, I cried a little on the inside when I wrote "document.write"

    <textarea id='ta' cols='80'></textarea>
    <button onclick="foo()">go</button>

Input:
10
{"":["ab","cd",""],"":["e<C>e"],"<C>":["z","",""]}

Output:
ccaaceeeeezeeeeedbbdd
accccceeeezeeeedddddb
aecezedeb
eaezebe
ccccaacezedbbdddd
eeeaaaceecacezedbdeedbbbeee
acaecaeaaeacccceeeeeeeaeeezeeebeeeeeeeddddbebbebdebdb
aaceezeedbb
aacezedbb
ceeaceecacaacezedbbdbdeedbeed

I think you can shorten this a bit by writing d=document; and reusing the value afterwards. Also, you might want to provide the character count.

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


text:
Partition of a positive integer N
Find the number of partitions of a positive integer n. Hope someone uses the explicit finite formula for the partition function defined in Jan Hendrik Brunier and Ken Ono paper here.
Sample Input
8
Sample Output
22

N is less than or equal to 1000.
Write the complete program. More than anything I would like to see the different approaches.

I added a winning criterion...

but a really deus-ex-machina one (IMO)

Java Solution
 public class IntegerPartition {
        public static void main(String[] args) {
            int n = 8; //set integer here!!
            int[][] a = new int[n + 1][n + 1];
            int i, j, k;
            for (i = 0; i < a.length; i++) {
                a[i][0] = 0;
                a[0][i] = 1;
            }
            for (i = 1; i < a.length; i++) {
                a[i][1] = 1;
                for (j = 2; j < a[0].length; j++) {
                    k = i - j;
                    if (k < 0)
                        a[i][j] = a[i][j - 1];
                    else
                        a[i][j] = a[i][j - 1] + a[k][j];
                }
            }
            i--;
            int answer = a[i][i - 1];
            System.out.println(answer + 1);
        }
    }

Python (109 89)
n=input()
s=0
l=[(n,n)]
while l:a,i=l.pop(0);s+=a==0;l+=[(a-i,i),(a,i-1)]*(a*i>0)
print s

Mathematica 11 chars
Sorry, no need to implement the algorithm
PartitionsP

Usage
%[8]
22

I have a book listing all partitions for numbers up to 10,000. Does that count as a 0 chars solution? :)

@Eelvex Just count the PDF length. I may accept that as a solution :)

Well, it's ~9000chars in bzip2 but I feel this is not too fair.

@Eelvex Perhaps you may consider posting a gzipped ASCII. version. :D

It's a fair answer. The question is not tagged code-golf, so there may be more interesting answers in other languages

@gnibbler sure, but it's also useful to know that http://www.wolframalpha.com/input/?i=PartitionsP+%2830%29 will return the answer, as it is based on Mathematica.

@belisarius, There are probably a lot of good code-challenge questions to be found by looking at the capabilities of Mathematica :) It certainly doesn't hurt to have the answers here even for languages that have it builtin (unless it is supposed to be a code-golf question). I think those are the type of things that are more likely to attract search engine traffic :)

Ruby - 95 chars
Based on Hoa Long Tam's solution
s=0
l=[[n=gets.to_i,n]]
(a,i=l.pop;a>0&&i>0&&l+=[[a-i,i],[a,i-1]];a==0&&s+=1)until l==[]
p s

Perl, 92 chars
Recursive solution using p(k,n) = number of partitions of n using numbers >= k. Uses dynamic programming and partitions 1000 in 2s on my machine.
sub p{my($k,$n)=@_;$c{$k,$n}||($c{$k,$n}=$k<$n?p($k+1,$n)+p($k,$n-$k):$n==$k)}print p(1,pop)

Ungolfed:
sub p {
    my ( $k, $n ) = @_;
    $c{$k,$n}
    || (
        $c{$k,$n} =
        $k < $n
            ? p($k+1,$n) + p($k,$n-$k)
            : $n == $k
    )
}
print p( 1, pop );

Perl, 70 chars
Since there was no time limit:
sub p{my($k,$n)=@_;$k<$n?p($k+1,$n)+p($k,$n-$k):$n==$k}print p(1,pop);

Partitions 50 in 2.3 s.

somebody downvoted everyone here so I suspect (s)he had no real reason.

@Eelvex yeap, flagging for mod attention

J, 72
Modified from the manual:
f=:[:(0<@-."1~>@{:)](,([:<@;(-i.)@#([,.(>:{."1)#])&.>]))@]^:[(<i.1 0)"_

eg
#f 8
22

APL, 23 characters
{⍵=0:1⋄+/⍵(-∇¨⍨⊢⌊-)⍳⍺}⍨

Haskell, 51 39
f=(%1)
0%k=1
n%k=sum[(n-r)%r|r<-[k..n]]

the % function gets two parameters - n and k, and returns the amount of partitions of n at which every part is at least k.
%'s definition works by choosing r to be the next part of the partition. we compute the amount of possibilities when this is the next part (note that all consequent parts must be bigger or equal to it) by a recursive call and sum all possibilities.


text:
How many squares are guarded by chess queens?
Today marks the 15th anniversary of Garry Kasparov's defeat against Deep Blue. Speaking of chess...
Input is a string that represents an 8x8 chess board containing only empty squares (.) and queens (Q). Output the number of squares that any queen can move to the next move. Queens can move any number of squares vertically, horizontally or diagonally.
Write either a program or a function. Shortest code wins, but most inventive solution gets the most upvotes.
Examples
Input:
Q.......
........
.Q......
........
........
........
........
........

Output:
37

Input:
QQQQQQQQ
QQQQQQQQ
QQQQQQQQ
QQQQ.QQQ
QQQQQQQQ
QQQQQQQQ
QQQQQQQQ
QQQQQQQQ

Output:
1

@Tim the correct output for the first test case is 36. I think you forgot to count the down-right diagonal from the second queen.

@Peter You're right, I missed that diagonal. That's what I get for trying to do a computer's job.

I get 37 for the first test case

@gnibbler The upper-left queen reaches 7 squares in each of 3 directions. Since we don't count overlaps, the other queen reaches 5 squares in each of 3 directions. (37+35=36)

@Tim: you are forgetting about c7 (for a total of 37)

@BRDP: You're right! I'll stop trying to count them and get on with my solution now. @gnibbler You're right too :)

I thought this question would attract more answers

This is a duplicate of http://codegolf.com/dancing-queens.
I guess it is okay to repost golf questions from other sources, but giving credit would seem appropriate.

@hallvabo: First, the problems are different. The answer to my second example would be 8 in the problem you linked. Second, it would be entirely reasonable that the same problem was thought of by two different sources.

@Tim: it's possible. Both challenges could also have a common ancestry (say, a textbook task).
And the difference is trivial, my solution to Dancing Queens is almost identical to gnibbler's 125 byte solution here.
Anyway, people who enjoyed this challenge might like to try Dancing Queen too :-)

Python - 125 chars
import os
s=os.read(0,99)
print sum(any('*'<s[i]!='Q'in s[i::j].split()[0]for j in(-10,-9,-8,-1,1,8,9,10))for i in range(71))

Seems not to count h1. Fill all squares except the bottom right corner and your script says 1.

@Tim, brainfart, i thought i was counting an extra one for the newline at the end because i kept getting 37 for case 1 :)

APL, 40 characters
≢⍸a<∨/(⍳8 8)∘.{∨/⊃=/(⊢,+/,-/)¨⍺⍵}⍸a←'Q'=

⍸a←'Q'= transforms the matrix in a nested vector whose elements are the coordinates of the given queens.
(⊢,+/,-/) returns for every cell: the coordinates, their sum, their difference.
{∨/⊃=/(⊢,+/,-/)¨⍺ ⍵} returns 1 if cells ⍺ & ⍵ share one coordinate, the coordinates sum or the coordinates difference; that is gives 1 if a queen can move orizontally, vertically or diagonally from ⍺ to ⍵.
⍵∘.{∨/⊃=/(⊢,+/,-/)¨⍺⍵}⍳8 8 applies the previous function to each queen and each cell in the chessboard.
∨⌿ returns the boolean matrix of cell reachable from some queens
≢⍸a< counts the cell reachable by the queens and not already occupied by queens.

What language is this?

Welcome to PPCG!

APL, 37 chars
{≢t~⍨⍸∨/(=/∘|∨0∘∊)¨(⍳8 8)∘.-t←⍸'Q'=⍵}

'Q'=⍵ gives boolean mask of queens
⍸ gives vector of coordinates (row, column) of queens
t← stores the result in var t
(⍳8 8)∘.- outer product: gives "distances" (∆row, ∆column) between all grid cells and queen cells
0∘∊ checks if either ∆row or ∆column is 0
=/∘| checks if ∆row = +/- ∆column
(=/∘|∨0∘∊)¨ checks both conditions for all "distances"
∨/ checks if at least one of those checks return true
⍸ gives vector of coordinates (row, column) of reachable cells
t~⍨ removes original queens' positions
≢ count

Welcome to PPCG!

you can save a char by computing the abs value a little earlier - right after the outer product

Java Solution
public class NewQueenProblem {
        public static int countMoves(String input){
            int moves=0;
            class Board{
                char data;
                boolean visited;
            }
            Board[][] board=new Board[8][8];
            int x=0;
            for (int i=0; i< 64; i++){
                board[x%8][i%8] = new Board();
                board[x%8][i%8].data=input.charAt(i);
                if ((i+1)%8==0)
                    x++;
            }
            for (int i=0; i< 8; i++){
                for (int j=0; j< 8; j++){
                    if (board[i][j].data == 'Q'){
                        for (int row=0; row<8; row++)
                            if (board[i][row].data != 'Q' && !board[i][row].visited)
                                { moves++; board[i][row].visited=true;}
                        for (int col=0; col<8; col++)
                            if (board[col][j].data != 'Q' && !board[col][j].visited)
                                { moves++; board[col][j].visited=true;}
                        int posX=i, posY=j;
                        while (posX < 8 && posY < 8){
                            if (board[posX][posY].data != 'Q' && !board[posX][posY].visited)
                            { moves++; board[posX][posY].visited=true;}
                            posX++; posY++;
                        }
                        posX=i; posY=j;
                        while (posX > 0 && posY > 0){
                            if (board[posX][posY].data != 'Q' && !board[posX][posY].visited)
                            { moves++; board[posX][posY].visited=true;}
                            posX--; posY--;
                        }
                        posX=i; posY=j;
                        while (posX > 0 && posY < 8){
                            if (board[posX][posY].data != 'Q' && !board[posX][posY].visited)
                            { moves++; board[posX][posY].visited=true;}
                            posX--; posY++;
                        }
                        posX=i; posY=j;
                        while (posX < 8 && posY > 0){
                            if (board[posX][posY].data != 'Q' && !board[posX][posY].visited)
                            { moves++; board[posX][posY].visited=true;}
                            posX++; posY--;
                        }
                    }
                }
            }
            return moves;
        }
public static void main(String[] args) {
        int moves = countMoves("Q................Q..............................................");
        //int moves = countMoves("QQQQQQQQQQQQQQQQQQQQQQQQQQQQ.QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ");
        System.out.println(moves);
    }
}

http://www.ideone.com/KFxxd oops  that's ~1800 characters

Please golf this.

APL, 50 chars
{≢(b~x)∩,(x←(,'Q'=⍵)/b←,⍳8 8)∘.+(⍳8)∘.×∘.,⍨1 0 ¯1}

In English:

∘.,⍨1 0 ¯1: computes all the pairs composed by -1, 0 or 1, i.e.: (0 0)(0 1)(0 -1)(1 0) and so on;
(⍳8)∘.×∘.,⍨1 0 ¯1: multiply all the pairs computed by all the number from 1 to 8, obtaining all the possible offsets of movement of the queen;
(x←(,'Q'=⍵)/b←,⍳8 8): puts is x the coordinates of the given queens;
∘.+: compute yet another outer sum, combining the position of the given queens with all the possible displacement offsets. This gives a multidimensional array of coordinate pairs of all the possible place where each of the queens might end up, including outside the board (whose valid coordinate pairs is in b)
(b~x)∩,: removes from the list b all the coordinates taken by the queens in the given (x) and intersects it with flattened array of pairs of all the possible positions of the queens
≢: count the remaining pairs

Try online sample 1.
Try online sample 2

The array literal at the end of your code could be 2-⍳3 if index origin is 1, 1-⍳3 if it's 0.

JavaScript 140 bytes

f=a=>a.split`
`.map((r,y,G)=>[...r].map((c,x)=>A+=c<"Q"&&G.some((R,Y)=>[...R].some((C,X)=>C>"."&&((d=X-x)*(D=Y-y)==0||d**2==D**2)))),A=0)&&A

console.log(f(`Q.......
........
.Q......
........
........
........
........
........`)==37)

console.log(f(`QQQQQQQQ
QQQQQQQQ
QQQQQQQQ
QQQQ.QQQ
QQQQQQQQ
QQQQQQQQ
QQQQQQQQ
QQQQQQQQ`)==1)

Perl 5, 172 + 3 (-pF) bytes
push@a,[@F]}{for$i(0..7){O:for$j(0..7){for$x(-1..1){for$y(-1..1){if($x|$y){$r=$i;$c=$j;$a[$i][$j]ne Q&&$a[$r][$c]eq Q&&++$\&&next O while(($r+=$x)^7)<8&&(($c+=$y)^7)<8}}}}}

Try it online!
There's got to be a better way to do it, but this at least works.


text:
Holiday Gift Exchange
Another problem from our internal golfing...this one around the holidays last year.
PROBLEM
Andy, Barb, Carl, Didi, Earl, and Fran are buying gifts for each other. Draw names for a gift exchange.

Each person buys one gift and receives one gift.
Nobody buys their own gift.
Running the solution multiple times should produce different results (giver-receiver pair should not be predictable or identical from run to run).

INPUT
None.
OUTPUT
Formatted as in this example:

Andy buys for Barb
  Barb buys for Carl
  Carl buys for Didi
  Didi buys for Earl
  Earl buys for Fran
  Fran buys for Andy

Should the output be sorted by name?

@Eelvex Nope, not necessary.

This was duplicated by a question today and the keyword I searched for didn't turn it up, so for future searches: derangement.

J, 57
(,.' buys for ',"1|.)(?~6){6 4$'AndyBarbCarlDidiEarlFran'

eg
   (,.' buys for ',"1|.)(?~6){6 4$'AndyBarbCarlDidiEarlFran'
Carl buys for Earl
Andy buys for Barb
Fran buys for Didi
Didi buys for Fran
Barb buys for Andy
Earl buys for Carl

I don't know [J], but would this work if the names had with different lengths?

No. The code exploits the fact that all names are 4 characters long. It'll work for different lengths with very few changes.

This also exploits that there is an even number of people. Note that if X gives to Y, Y will always give to X too.

Japt -R, 41 bytes
`AÌ)B¼C¤E¤FÎÂDi¹`qe ö¬ê1 ò mq` ¿ys f

-2 bytes thanks to @Oliver!
Try it!
This is the approach I took at a high level:

uncompress a string containing participants names
split string into an array
shuffle it
assign each person to the person with the next highest index
the last person in the array gets assigned to the first

I have a little history with this problem as I created a "secret santa" program for my work years ago. We ended up asking a few job applicants to work through it as well :)

@Oliver - thanks for the tips! It looks like the ã is not returning a pair that links the first to the last element. I'm working on a way to get this to work, but thought I'd let you know. Thanks again though! https://ethproductions.github.io/japt/?v=1.4.6&code=YEHMKUKHvEOHpEWHpEbOwkRpuWBxZSD2rOMg&input=LVE=

43?

Ah, you're right. I think this would work for 42

41 bytes

Wait what does the "q" in the .ö("q") do

The letter "q" may be irrelevant. I think you throw any string into that function and it returns a "random permutation" of the array. I'm not totally sure, but that's the best I was able to determine.

Ah, it's .ö(s) where s is any string

You forgot to mention the mirror part (also, wonder how useful a titlecase builtin would be for string challenges like this)

Might be shorter using no delimiter (using ò4 instead) but I'm too bad at Japt to modify Shaggy's compressor to work with no delimiter

also 41 :/ (metagolfer)

lowercase is golfier but sadly no titlecase

@Shaggy - Thanks for the bounty!

Haskell, 241 189 characters
import Data.List
import Random
main=randomRIO(0,719)>>=mapM_ putStrLn.f
f n=map(\(x,y)->x++" buys for "++y).zip(l n).tail$cycle$l n
l=(permutations(words"Andy Barb Carl Didi Earl Fran")!!)

Fully random output (that still satisfies the spec).
This generates all permutations of the list of the names, picks one at random (I think this is the shortest way in Haskell to shuffle a list - if anyone has anything smaller, I'd appreciate it), and then each person then buys a present for the next person in the list.

I tried this ad-hoc, I'm not shure whether it works: http://paste.ubuntuusers.de/399798/

@Anon: permutations$words"Andy Barb Carl Didi Earl Fran" and some other tricks I tried in my improved version. I forgot, that permutations isn't included in the 98 List, so you have to use the long name either. Have a look at it.

And for your special purpose: r=tail.cycle. and than inline it.

Got it down to 202 chars. Have a look: http://paste.ubuntuusers.de/399799/

And for 189 chars, replace the third line in my example with: main=randomRIO(0,719)>>=mapM_ putStrLn.f

Golfscript: 72 64 57 chars
"AndyBarbCarlDidiEarlFran"4/{;9rand}${.n+\' buys for '}%(

Tests
$ golfscript codegolf-838.gs
Fran buys for Carl
Carl buys for Andy
Andy buys for Barb
Barb buys for Didi
Didi buys for Earl
Earl buys for Fran

$ golfscript codegolf-838.gs
Didi buys for Earl
Earl buys for Andy
Andy buys for Barb
Barb buys for Carl
Carl buys for Fran
Fran buys for Didi

Thanks gnibbler for "AndyBarbCarlDidiEarlFran"4/, updated and got 7 chars less
57 chars solution is basically by Nabb :D, and also noticed that ;9rand is more random than my 6rand*

"AndyBarbCarlDidiEarlFran"4/

ah ha, thank you @gnibbler, cool, going to update it.

Not sure why you're using 6rand* -- 0=rand or maybe ;9rand is preferable. For the loop, {.n+\' buys for '}%( is shorter..

heh; became same chars count with J now :D and thank you @Nabb, I used 6rand* because I thought It will equally randomize the 6 items array (I think I was wrong, since ;9rand looks really random than mine)

Windows PowerShell, 83
$i=random 5
($n=-split'Andy Barb Carl Didi Earl Fran')|%{"$_ buys for "+$n[++$i%6]}

History:

2011-02-11 22:01 (136) – First attempt.
2011-02-11 22:05 (130) – Inlined a few things. Shuffling the names now, not the indexes.
2011-02-13 16:13 (128) – I don't need the modulus as $i will be recreated every time.
2011-02-13 16:20   (87) – Borrowed the idea from Anon.'s C# solution. Just generate a random offset and then just let them gift in circles.
2011-02-13 16:26   (83) – Changed random number generation and indexing. Pulled $_ into the string to save the +.

c99 -- 252 characters
#include <stdio.h>
#define G for(i=0;i<6;i++)
char*n="Andy\0Barb\0Carl\0Didi\0Earl\0Fran",*p[7];int i,j;int main()
{FILE*r=fopen("/dev/random","r");G p[i]=n+5*i;G{j=fgetc(r)%6;p[7]=p[j]
;p[j]=p[i];p[i]=p[7];}G printf("%s buys for %s\n",p[i],p[(i+1)%6]);}

Slight improvement by taking advantage of the circular nature of the permutation. This version always builds a loop-like buying strategy, so it is less random than the previous (271 character) version, but I believe it still meets the spec.
Requires a platform that has a working /dev/random. I ought to be able to knock about 8 off by omitting the \0s in the big string, but my libc doesn't seem to be dealing with %4s print specifiers the way the man page says.
The shuffle is bad, but doing it that way prevents me from having to check on "Foo buys for Foo" conditions.
Readable:
#include <stdio.h>

char *n="Andy\0Barb\0Carl\0Didi\0Earl\0Fran",
  *p[7]; /* 7th cell for temp */
int i,j;

int main(){
  FILE*r=fopen("/dev/random","r");
  for(i=0;i<6;i++)
    p[i]=n+5*i;   /* Initialize the pointers */
  for(i=0;i<6;i++){
    j=fgetc(r)%6; /* Poor numeric properties. Cest le Code Golf */
    p[7]=p[j];
    p[j]=p[i];
    p[i]=p[7];
  }
  for(i=0;i<6;i++)
    printf("%s buys for %s\n",p[i],p[(i+1)%6]);
}

Python - 118 chars
from random import*;L="Andy Barb Carl Didi Earl Fran".split()
for i in sample(range(6),6):print L[i-1],"buys for",L[i]

Python - 120 chars
import random as R;L="Andy Barb Carl Didi Earl Fran".split();R.shuffle(L)
for i in range(6):print L[i-1],"buys for",L[i]

R - 85 characters
paste(n<-sample(c('Andy','Barb','Carl','Didi','Earl','Fran')),'buys for',n[c(6,1:5)])

Python - 154 chars
import random as R;L="Andy Barb Carl Didi Earl Fran".split();M=L[:]
while any(map(str.__eq__,L,M)):R.shuffle(M)
for i in zip(L,M):print"%s buys for %s"%i

Apologies, my Python is severely lacking...is the while loop there basically looping until it finds a solution that avoids "X buys for X"?

@Steve: That's pretty much what it does. map calls str.__eq__ on each pair of corresponding values in L and M, and the loop keeps going until none of them are true.

@Steve, yes. although it is probably shorter to jsut shift the records by a random amount from 1 to 5, I think that's not in the spirit of the question

When I first posed the question at work, you're exactly right. My coworkers quickly pointed out it wasn't ruled out by my definitions...so I left it as is when posting here.

C#, 210 183 characters
using System;class a{static void Main(){var n="Andy Barb Carl Didi Earl Fran".Split();var c=0,i=new Random().Next(1,6);for(;c<6;c++)Console.WriteLine(n[c]+" buys for "+n[(c+i)%6]);}}

Heaps of boilerplate :(
This solution isn't totally random - there are always one or more "loops" of people e.g. A->C->E->A, and the offsets are always the same in the loops. However, it is not possible to predict the output of a particular run unless you have part of that output.

That's the interpretation I was intending (and basically the solution we landed on as well).

Should be 210. are you counting the newline at the end of the file?

@gnibbler: I probably was. I just catted the file into wc, I'm not really going to count that by hand.

What about var n="Andy Barb Carl Didi Earl Fran".Split()? Saves 16 bytes. You can leave out the argument to Main(), which saves another 9 bytes. And you can combine the declaration of c and i: int c,i=...;for(c=0;... which saves another two.

@Joey: Tweaked it as per your suggestions, thanks.

D: 233 Characters
import std.random,std.stdio;void main(){auto p=["Andy","Barb","Carl","Didi","Earl","Fran"];auto q=p.dup;o:while(1){for(int i;i<6;++i)if(p[i]==q[i]){randomShuffle(q);continue o;}break;}foreach(i,a;p)writefln("%s buys for %s",a,q[i]);}

More Legibly:
import std.random, std.stdio;

void main()
{
    auto p = ["Andy", "Barb", "Carl", "Didi", "Earl", "Fran"];
    auto q = p.dup;

    o:while(1)
    {
        for(int i; i < 6; ++i)
            if(p[i] == q[i])
            {
                randomShuffle(q);
                continue o;
            }

        break;
    }

    foreach(i, a; p)
        writefln("%s buys for %s", a, q[i]);
}

Python (175)
import random as r
n=['Andy','Barb','Carl','Didi','Earl','Fran']
m=n[:]
r.shuffle(m)
b=' buys for '
for i in n:
 h=m.pop()
 while h==i:
  m.append(h)
  h=m.pop()
 print(i+b+h)

Scheme, 173
Gives one of two solutions.
(define(m lst)
    (printf"~v buys for ~v~n"(car lst)(cadr lst))
    (if(eq?(cadr lst)'Andy)0(m(cdr lst)))
)
(m((if(odd?(random 2))reverse values)'(Andy Barb Carl Didi Earl Fran Andy)))

Ruby - 89 chars
(a=%w(Andy Barb Carl Didi Earl Fran).shuffle).zip(a.reverse).each{|e|puts e*' buys for '}

Output:
Andy buys for Didi
Barb buys for Earl
Fran buys for Carl
Carl buys for Fran
Earl buys for Barb
Didi buys for Andy

You can use map instead of each.

the problem with this solution is that if you have an odd number of people the middle person will gift themselves
Earl buys for Mark
Fran buys for Andy
Barb buys for Carl
Didi buys for Didi
Carl buys for Barb
Andy buys for Fran
Mark buys for Earl

MathGolf, 41 bytes
"δ%è╘+µ√♂JÇ"2/$╦╕ää▐δáw_╪" buys for "+m+n

Try it online!
Explanation
This is not guaranteed to produce each case with equal probability, but it does produce different results each run. One byte could be removed if I had a shuffle operator, but that's for another day.
"δ%è╘+µ√♂JÇ"                                push the string "δ%è╘+µ√♂JÇ"
            2/                              split into segments of two characters
              $                             transform to ordinals using base 256
               ╦                            fetch dictionary words (['Andy', 'barb', 'Carl', 'Earl', 'Fran'])
                ╕ää                         Push "didi"
                   ▐                        append to end of list
                    δ                       capitalize all strings in list
                     áw                     sort by random character in each string (shuffle)
                       _                    duplicate TOS
                        ╪                   right-rotate bits in int, list, str
                         " buys for "       push the string " buys for "
                                     +      Add to all strings in list
                                      m+    zip add the two arrays
                                        n   join array with newline