text:
2-dimensional ray tracing
The challenge is to implement a 2-dimensional ray tracing program, text-based.
Sources of white light are @ symbols. R, G and B are light filters. / and \ are mirrors with 80% reflectivity. ? is a light sensor. >, <, ^ and V combine light in the appropriate direction (e.g. if one red and one green came into a > the light would be emitted toward the right and it would be yellow). Other non-whitespace characters absorb all light. Light is emitted from @ symbols in four directions.
When the program is run, it should produce output the same as the input, but with traced rays. Because this is 2 dimensional, and I guarantee in the input no rays will ever cross, there will be no problem with that. Each ray should be represented by a letter; r=red, g=green, b=blue, c=cyan, m=magenta, y=yellow, w=white. There won't be any ternary colors, ever. The casing is important to differentiate it from the input. After that output, the values of light captured by the question marks (in order of their appearance, left to right top to bottom) should be outputted as percentages and colors. For example, this input:
 /                  @
                    -
 \R>                 ?

 @B/

Should give the output:
 /wwwwwwwwwwwwwwwwww@w
 w                  -
w\R>mmmmmmmmmmmmmmmmm?
 w b
 @B/

#1: 72% Magenta

Another important point to note - when two colors are combined using a "prism" (the arrows) the strength of the combined light becomes the average strength of the two. Output must be exactly as specified (e.g. #x: [x][x]x% Color).
If your language cannot read from STDIN and write to STDOUT, create a function (anonymous or lambda when available) that accepts the input as an argument and returns the result.
Directives to the compiler, structures required or recommended for all or most programs created in the language, etc. can be omitted. For example, #include and using directives (but not #define) may be removed in C-style languages, #/usr/bin/perl -options in Perl, and
 Module Module1
      Sub Main()
      End Sub
 End Module

in VB.NET, for example. If you import namespaces or add include directives, please note them in your answer.
Is that hard enough, now? :)

Related to Code Golf: Lasers on Stack Overflow.

The behaviour of the mirrors in your example doesn't make sense. You have a \ (escaping is broken) affecting light which is going straight past it. It would seem much more sensible to have light come in on the same row as the mirror and leave on the same column, or vice versa. Similarly the > is capturing light which is going straight past it. And if the w from the top goes through that R, so should the b from the bottom. Finally (I think), you're wrong about rays not crossing. To give a one-line example, what would the correct output be for @R>  B@?

Why did you add a random w and break all of the spacing? And the light is not going straight past it, not sure what you mean.

@minitech, that @ in the bottom-left emits light in all four directions, doesn't it? So in particular, it emits that w. And I haven't broken any spacing, at least as rendered in Chromium. As to going straight past it, my edit may clear that up.

Okay, I've rolled back and fixed the spacing (I have no idea what happened there). I was actually talking about a w that came from nowhere in particular.

Ok, a few characters have moved. But the mirrors are still inconsistent, just in a different way. The one in the top-left isn't behaving as the other two.

minitech: As an advice for future tasks: Ask for comments in the Sandbox or Puzzle Lab first which should suffice to iron out inconsistencies and early problems with tasks. That way, once you post the task here, you'll know it has been checked (and maybe implemented) already by some others.

What if two rays intersect?

As I point out in the question, I guarantee that they never will for the test input.

(my CTRL+F missed) and assuming spaces are not padded?

No, spaces are not padded.

@minitech, actually in the example you posted, rays do cross one against the other: The middle mirror, the one besides the B filter, lets light through from top and bottom. So the top mirror also reflects light back to the top right source (from the bottom source). As it stand there is no problem, but if you start placing filters somewhere on the path, you got problems. Lastly, the bottom left source should have a w on its left hand side (it emits in four directions right?).

what's the base of the color? (1.0 for 100%, 255 for 100% or 100 for 100%?)

@SHiNKiROU: What do you mean? It doesn't matter in this case - the output is measured in percentages. @asoundmove: Mirrors may reflect multiple rays, but they will always be on different sides.

So assume all prisms (things that combine light) only receive two beams?

No, but the combination will only ever be of either two distinct primary colors or several duplicate secondary colors.

@minitech, Sorry I assumed that as they reflect 80%, they also let light through 20%. Incorrect assumption obviously.

Don't know how I missed this on the fist pass, but also related: http://codegolf.stackexchange.com/questions/3772/illuminate-a-mirrored-room?rq=1

@dmckee: Your first pass on this question? Well, the other one came after :)

@minitech Lol. Yep.

Python, 602 559 614 chars
import sys
S=sys.stdin.readlines()
X=max(len(s)for s in S)
I='#'*X+''.join(t[:-1]+' '*(X-len(t))+'\n'for t in S)+'#'*X
L=len(I)
R=range(L)
B=[0]*L
C=[0]*L
for p in R:
 if'@'!=I[p]:continue
 for d in(1,-1,X,-X):
  q=p;c=7;b=100.
  while 1:
   q+=d;a=I[q];B[q]+=b;C[q]|=c
   if a in'\/':d=(ord(a)/30-2)*X/d;b*=.8
   elif a in'RGB':c&=ord(a)/5-12
   elif a in'><^V':d={'>':1,'<':-1,'^':-X,'V':X}[a];b/=2
   elif' '!=a:break
print''.join(I[p]if' '!=I[p]else' bgcrmyw'[C[p]]for p in R[X:-X])
i=0
for p in R:
 if'?'==I[p]:i+=1;print'#%d:'%i,'%.0f%%'%B[p],[0,'Blue','Green','Cyan','Red','Magenta','Yellow','White'][C[p]]

Edit: fixed so it doesn't need trailing spaces.

Almost - but the test case result is incorrect. See: http://ideone.com/kUTxE . +1 anyways, though, it's great!!!

@minitech:I think this has to do with the lack of trailing spaces.  My code assumes that each row is the same length, padded with spaces if necessary.  Is that not the case?  If so, then how do you know, e.g., how far the upper light source goes to the right?

Using the length of the longest line to pad it, you can figure out the whole grid. However, even when padded with spaces, it gives this (input #4): http://ideone.com/kUTxE

@minitech: you're missing a space on the 4th line.  I'll fix my code to not require trailing spaces.

Oh, wow it does work!! Good job. But yes, it would be good if it didn't require padding.

F#
#nowarn "0025"

open System

type MirrorDirection = bool
type LightDirection = bool * bool
type Sq =
  | Air // [ ]
  | Mirror of MirrorDirection // [/] [\]
  | FilterR
  | FilterG
  | FilterB
  | Sensor // [?]
  | Combine of LightDirection // [^] [v] [<] [>]
  | Emitter // [@]
  | Wall of Char // non-whitespace

let [ mL; mR ] : MirrorDirection list = [ true; false ]
(* true T^/
       F</>F
        /vT   false
 *)
let [ dN; dS; dW; dE ] : LightDirection list = [ true, true; false, true; true, false; false, false ]
let bounce (m : MirrorDirection) ((a, b) : LightDirection) =
  m <> a, not b

let dv (a : LightDirection) =
  if a = dN then 0, -1
  elif a = dS then 0, 1
  elif a = dW then -1, 0
  else 1, 0

let fo<'a> : (('a option)[,] -> 'a seq) =
  Seq.cast
  >> Seq.filter Option.isSome
  >> Seq.map Option.get

let input = Console.In.ReadToEnd().Replace("\r\n", "\n")
let sqs =
  input.Split('\n')
  |> Array.map (fun x ->
    x.ToCharArray()
    |> Array.map (
      function
      | ' ' | '\t' | '\v' -> Air
      | '/' -> Mirror mL
      | '\\' -> Mirror mR
      | 'R' -> FilterR
      | 'G' -> FilterG
      | 'B' -> FilterB
      | '?' -> Sensor
      | '^' -> Combine dN
      | 'v' -> Combine dS
      | '<' -> Combine dW
      | '>' -> Combine dE
      | '@' -> Emitter
      | x -> Wall x
    )
  )

let w =
  Array.map Array.length sqs
  |> Set.ofArray
  |> Set.maxElement
let h = sqs.Length

let ib x y = -1 < x && x < w && -1 < y && y < h

let arr = Array2D.init w h (fun x y ->
  if x < sqs.[y].Length then
    sqs.[y].[x]
  else
    Air
)

let board =
  Array2D.map (
    function
    | _ -> 0.0, 0.0, 0.0
  ) arr

let mutable rays =
  Array2D.mapi (fun x y a ->
    match a with
    | Emitter -> Some(x, y)
    | _ -> None
  ) arr
  |> fo
  |> Seq.map (fun (x, y) ->
    [|
      dN, x, y, 1., 1., 1.
      dS, x, y, 1., 1., 1.
      dW, x, y, 1., 1., 1.
      dE, x, y, 1., 1., 1.
    |]
  )
  |> Seq.reduce Array.append

for i = 0 to w * h * 2 do
  rays <-
    rays
    |> Array.map (
      (fun (dir, x, y, r, g, b) ->
        let dx, dy = dv dir
        dir, x + dx, y + dy, r, g, b
      )
      >> (fun (dir, x, y, r, g, b) ->
        if ib x y then
          match arr.[x, y] with
          | Wall _ -> Array.empty
          | Sensor -> [| dir, x, y, r, g, b |]
          | FilterR -> [| dir, x, y, r, 0., 0. |]
          | FilterG -> [| dir, x, y, 0., g, 0. |]
          | FilterB -> [| dir, x, y, 0., 0., b |]
          | Mirror d -> [| bounce d dir, x, y, r * 0.8, g * 0.8, b * 0.8 |]
          | _ -> [| dir, x, y, r, g, b |]
        else
          Array.empty
      ))
    |> Array.concat
  Array2D.mapi (fun x y a ->
    match a with
    | Combine d -> Some(x, y, d)
    | _ -> None
  ) arr
  |> fo
  |> Seq.iter (fun (x, y, d) ->
    for i = 0 to rays.Length - 1 do
      let (d', x', y', r, g, b) = rays.[i]
      if x' = x && y' = y then
        rays.[i] <- (d, x, y, r, g, b)
  )
  for d, x, y, r, g, b in rays do
    if ib x y then
      match board.[x, y] with
      | r', g', b' -> board.[x, y] <- r + r', g + g', b + b'

printfn "%s" (
  let mutable s = ""
  for y = 0 to h - 1 do
    for x = 0 to w - 1 do
      s <- s + (match arr.[x, y] with
                | Air ->
                  match board.[x, y] with
                  | r, g, b ->
                    if r + g + b = 0.0 then ' '
                    else
                      if g = 0.0 && b = 0.0 then 'r'
                      elif r = 0.0 && b = 0.0 then 'g'
                      elif r = 0.0 && g = 0.0 then 'b'
                      elif r = 0.0 then 'c'
                      elif g = 0.0 then 'm'
                      elif b = 0.0 then 'y'
                      else 'w'
                | Wall z -> z
                | Mirror z -> if z = mL then '/' else '\\'
                | FilterR -> 'R'
                | FilterG -> 'G'
                | FilterB -> 'B'
                | Sensor -> '?'
                | Combine z -> if z = dN then '^' elif z = dS then 'v' elif z = dW then '<' else '>'
                | Emitter -> '@'
                |> sprintf "%c")
    s <- s + "\n"
  s
)

Array2D.mapi (fun x y a ->
  match a with
  | Sensor -> Some(x, y)
  | _ -> None
) arr
|> fo
|> Seq.iteri (fun i (x, y) ->
  let (r, g, b) = board.[x, y]
  let desc =
    if r + g + b = 0.0 then "None"
    elif g = 0.0 && b = 0.0 then "Red"
    elif r = 0.0 && b = 0.0 then "Green"
    elif r = 0.0 && g = 0.0 then "Blue"
    elif r = 0.0 then "Cyan"
    elif g = 0.0 then "Magenta"
    elif b = 0.0 then "Yellow"
    else "White"
  let avg = int((r + g + b) * 100.0 / (match desc with
                                       | "White" | "None" -> 3.0
                                       | "Red" | "Green" | "Blue" -> 1.0
                                       | _ -> 2.0))
  printfn "#%d: %d%% %s" (i + 1) avg desc
)

Ungolfed but still awesome! +1.


text:
Draw dice results in ASCII
Show the random result of a dice toss if done with a cube shaped die, in ASCII.
$ dice

should result in one of
-----
|   |
| o |
|   |
-----

-----
|o  |
|   |
|  o|
-----

-----
|o  |
| o |
|  o|
-----

-----
|o o|
|   |
|o o|
-----

-----
|o o|
| o |
|o o|
-----

-----
|o o|
|o o|
|o o|
-----

You have not defined the metric here. Is this meant to be a code golf? It is always worth discussing possible tasks in the puzzle lab chat or the sand box on meta so that you can address these kinds of questions before you go live.

Sorry, I thought the metric always is the number of characters? Thanks for pointing me to the chat and then sand box on meta. If this question falls flat on it face then I will delete it. I hate to do it right now, just in case someone already started working on it.

Ah...note the site name "Programming puzzles and code golf" (and yeah, I thought it scanned better the other way round, too). You will also find one-liners, king-of-the-hill tournaments, and code-challenges (everything else, but you are still supposed to establish an objective metric for winning), so it is necessary to say and to apply the appropriate tag.

http://english.stackexchange.com/questions/243/is-it-ok-to-say-dice-and-dices-instead-of-die-and-dice

According to XKCD #221, alert('-----\n|o  o|\n|     |\n|o  o|\n-----'); is a correct program.

If you remove the ascii-art tag, I can offer my 39char-solution print("⚀⚁⚂⚃⚄⚅"(util.Random.nextInt(6))) (utf-art).

Golfscript, 56 characters
"-"5*n"|":|"o "1/:&6rand:§1<=" "&§3<=|n|&§5<=]&§2%=1$-1%

The solution can be tested here.

Python, 112 110 chars
from random import*
r=randrange(6)
C='o '
s='-----\n|'+C[r<1]+' '+C[r<3]+'|\n|'+C[r<5]
print s+C[r&1]+s[::-1]

Those compares in the array indexer are totally impressive!

Ditto! I like how you used the symmetry of the die as well :)

Could you use something like id(0)%7%6? It's not going to be a uniform distribution, but it's significantly shorter...

@Nabb: that isn't very random.  In particular, it is often the same from run to run, so it wouldn't be very useful in generating random dice rolls.

Ruby 1.9, 80 84 characters
z=" o";$><<(s=?-*5+"
|#{z[2/~a=rand(6)]} #{z[a/3]}|
|"+z[a/5])+z[~a%2]+s.reverse

I liked the +s.reverse

Windows PowerShell, 89 93 96 97 101 119 characters
-join('-----
|{0} {1}|
|{2}{3}'-f'o '[$(!($x=random 6);$x-lt3;$x-ne5;$x%2)])[0..14+13..0]

Python, 109 unicode characters
#coding:u8
print u"鱸헓ȅ᪮ԅ᪅餠☏汁끝鐸즪聗K糉툜㣹뫡燳闣≆뤀⩚".encode("u16")[2:].decode("zlib").split("\n\n")[id(list())%7-1]

Note: This does not used random function, so it will be not so random like others does.

Perl, 74 chars
Run with perl -M5.010.
$-=rand 6;$_="-----
|0 2|
|4";s/\d/$->$&?o:$"/ge;say$_,$-&1?$":o,~~reverse

(Note that the newlines in the listing are part of the string, and not just inserted for legibility.)
If you find yourself wondering what the heck the $->$ operation does, the following reading notes may be helpful:

The variable $- automatically truncates its assigned value to an integer.
The variable $" is preset to a single space.
o is a bareword (representing "o").

First time golfer
Python, 161 chars
from random import*
n=randint(1,7)
o,x='o '
a='-'*5
b=(x,o)[n>3]
d=(x,o)[n>5]
c=(x,o)[n>1]
print a+'\n|'+c+x+b+'|\n|'+d+(x,o)[n%2]+d+'|\n|'+b+x+c+'|\n'+a

JavaScript, 215 213 212 145 135
r=Math.random()*6|0;alert('-----\n|'+[r>2?'o o':r?'o  ':'   ',r%2?r>3?'o o':'   ':' o ',r>2?'o o':r?'  o':'   '].join('|\n|')+'|\n-----');

Beat mellamokb, but I changed my original solution completely. If you want this to look good, use Google Chrome or something, change alert to console.log, and voilà.
Edit: borrowed mellamokb's |0 trick to save some characters.

@minitech: BTW, your M=Math trick that I tried to steal actually ends up being one character longer

@mellamokb: I know, I thought originally that I would use it more...

@minitech: You can save two chars with [s.substr(0,3),s.substr(3,3),s.substr(6,3)].join('|\n|')

@mellamokb: Nope; s is an array. I'm going to restart and try again.

@minitech: Here we go again :-) Evolution of the best answer by competition.  Now I'm down to 137, but you can borrow one of my tricks and save possibly 10 chars.

@minitech: Love the x?x?x:x:x.  Didn't know you could do that without any parens, lol!  Wow and x?x:x?x:x?  Impressive and creative.  I'm learning so much through these exercises :-)

@minitech: pssst. mutual up-vote?

@minitech: Wow are you really only 13 years old?? lol...

@mellamokb: Sure, mutual up-vote :-) Yes, I'm 13 also.

I know this thread is old, but... any time you have a 3-char constant string that you use at least 3 times ('   ' in this case) it is better to put it into a variable. Doing that and changing how the join is done will knock 9 chars off the above (I see 137 for the above if you ignore the ; at the end, but this version is 128 chars): r=Math.random(d='-----',z='|   |',t='|o o|')*6|0;alert([d,r>2?t:r?'|o  |':z,r%2?r>3?t:z:'| o |',r>2?t:r?'|  o|':z,d].join('\n')).

Common Lisp 170
(let*((r(random 6))(a "-----
|")(c "o")(d " ")(e "|
|")(f(concatenate 'string a(if(< r 1)d c)d(if(< r 3)d c)e(if(> r 4)c ))))(concatenate 'string f(if(evenp r)c d)(reverse f)))

Note that the newlines are significant.  Unlike these silly "modern" languages, Common Lisp favors readability over succinctness, so we have the cumbersome "concatenate 'string..." construct and no succinct way to reference a character in a string.

JavaScript (169 168 141 137)
r=Math.random()*6|0;s='-----\n|'+(r>0?'o ':'  ')+(r>2?'o':' ')+'|\n|'+(r-5?' ':'o');alert(s+(r%2?' ':'o')+s.split('').reverse().join(''))

Doesn't look quite right in alert because it's not fixed-width font, but rest assured it is correct, or test by emitting a
 tag and doing writeln :-)
Proof: http://jsfiddle.net/d4YTn/3/ (only works in JS 1.7-compliant browsers, such as FF2+)
Credits: Hacked Math trick from @minitech and die print logic from @Keith.
Edit: Remove Math trick from @minitech because it actually made it longer :-)
Edit 2: Save 17 chars. Borrow trick from @Keith for taking advantage of dice symmetry.  Use trick for simplifying converting random number to int.
Edit 3: Remove 1+ to shift random number from 1-6 to 0-5 and save 2 chars.  As a result, I can also change r%2-1 to r%2 and save another 2 chars.
Edit 4: jsfiddle is working again. Updated :-)

E4X! And I can't believe Chrome won't support it!

Heh, I beat you finally :)

Two characters, now, using your |0 trick :-)

It works in Chrome for me.

PHP 119 126 128 131 188 201 213 234 239
<?$c=($r=rand()%6)%2?$r>4?'o ':'  ':' o';$b=$r>0?$r<3?'o  ':'o o':'   ';echo$a="-----\n|$b|\n|$c",substr(strrev($a),1);

The closing ?> can be omitted, saving you 2 characters.

You can inline the declaration for $r, saving another character. The space after echo can be omitted as well. You can inline the initialization of $a too, bringing you to 128. Putting line breaks directly into the string instead of escaping them with \n saves another two characters, then.

Python 108 114 119 121 122 129
wtf! looks like 1st solution ?! but iam not ... cheater
108
import random as R
i=R.randint(1,6)
X=' 0'
A='-----\n|%s %s|\n|'%(X[i>1],X[i>3])+X[i>5]
print A+X[i%2]+A[::-1]

119
import random as R
i=R.randint(1,6)
X=' 0';a=X[i>5]
A='-----\n|%s %s|\n|%s|'%(X[i>1],X[i>3],a+X[i%2]+a)
print A+A[-6::-1]

Python 133
import random as R
i=R.randint(1,6)
a='   ';b='0 0'
A='-----\n|'+((a,'0  ')[i>1],b)[i>3]+'|\n|'
print A+((a,' 0 ')[i%2],b)[i>5]+A[::-1]

F# - 165 161 characters
(System.Random()).Next 6|>fun x->[for y in[x>0;x%2=0;x>2;x=5]->if y then"o"else" "]|>fun[a;b;c;d]->printf"-----\n|%s %s|\n|%s%s%s|\n|%s %s|\n-----"a c d b d c a

perl - 111 103 101
$n=int rand 6;
($t="-----\n|0 1|\n|232|\n|1 0|\n-----\n")=~s/(\d)/5639742>>6*$1>>$n&1?o:$"/eg;
die$t;

+1 for using die instead of print/say

APL (69)
5 5⍴(5⍴'-'),{⊃⍵↓' o|'}¨2,(⌽M),2,2,(N∊¨6(1 3 5)6),2,2,2,⍨M←3 6 1>⍨N←?6

Golfscript 80 65
6rand):^;'-'5*n+:_[^6&0^4&^6=].^1&+-1%+3/{'|'\{'o'' 'if+}/'|'n}/_

The program can be tested here

Haskell, 154 162 167 172 chars
import System.Random
main=randomRIO(1::Int,6)>>=putStrLn. \x->let{h="-----\n|"++c(>1):' ':c(>3):"|\n|"++[c(>5)];c f|f x='o'|True=' '}in h++c odd:reverse h

It uses roughly the same idea as the Python one.
Readable version:
import System.Random

main = do
    x <- randomRIO (1 :: Int, 6)
    putStrLn (render x)

render x = str ++ check odd ++ reverse str
  where
    str = concat
        [ "-----\n|"
        , check (> 1)
        , " "
        , check (> 3)
        , "|\n|"
        , check (> 5)
        ]
    check f = if f x then "o" else " "

PHP 126 127 179
<?$x=($r=rand(1,6))>3?"o o":($r<2?"   ":"o  ");$z=$r>5?"o o":($r%2==0?"   ":" o ");$v="-----\n|$x|\n";echo"$v|$z|".strrev($v);

Another PHP solution. I came to the almost same solution by Oleg.

C - 215
#include <time.h>
#include <stdlib.h>
main(){char a[]=A,b[]=B,c=3,d=(srand(time(0)),rand()%6+1),e=d-2;if(d==1)a[5]=C;else{while(--e>-1)a[b[D[d-3]-48+e]-48]=C;a[0]=a[10]=C;}p(E);while(--c>-1)p("|%s|\n",a+c*4);p(E);}

Compiles with:
cl /DA="\"   \0   \0   \"" /DB="\"5282582468\"" /DC='o' /DD="\"0136\"" /DE="\"+---+\n\"" /Dp=printf dice.c

Is that sorta cheating with all those flags on the command-line?  I don't understand it the /DA /DB /DC.. thing.

My compiler does not understand the /D switch... Please don't cheat by putting random defines into the compilation command.

Python (153)
This is by far not the smallest submission, i just thought it looked nice :)
import random as r
print"""-----
|%c %c|
|%c%c%c|
|%c %c|
-----"""%tuple(
r.choice([
"   o   ",
"o     o",
"o  o  o",
"oo   oo",
"oo o oo",
"ooo ooo"]))

Q (120 chars)
dice:{(`t`e`l`c`r`w!5 cut"-----|   ||o  || o ||  o||o o|")(,/)(`t;(`e`c`e;`l`e`r;`l`c`r;`w`e`w;`w`c`w;`w`w`w)(*)1?6;`t)}

Usage:
dice[]

C, 168 164 163 chars
Sorry if I'm a bit late to the party, but since no answer has been accepted yet, and the only other C solution was somewhat longer, here goes...
#include<stdio.h>
main(){srand(time(0));char*o="O ",r=rand()%6,i=o[r<1],j=o[r<3],k=o[r<5];printf("-----\n|%c %c|\n|%c%c%c|\n|%c %c|\n-----\n",i,j,k,o[r&1],k,j,i);}

You can remove the include and save another 18 chars, but then it doesn't compile without warnings.
Edit:
using user23241's command-line trick, the shortest C code that produces the result (without compiler warnings) is only 12 chars:
#include I
M

At least if you cheat and use the following command line to compile:
gcc -DI="<stdio.h>" -DM="main(){srand(time(0));char*o=\"O \",r=rand()%6,i=o[r<1],j=o[r<3],k=o[r<5];printf(\"-----\n|%c %c|\n|%c%c%c|\n|%c %c|\n-----\n\",i,j,k,o[r&1],k,j,i);}" dice.c -o dice

c, 140 chars
r,i,s;main(){srand(time(i=0));r=rand()%6;for(s=-1;i-=s;)putchar("\n|   |-o"[i>5?i==8&&r||i==10&&2<r||i==14&&4<r||i==15&&(s=1)&~r?7:i%6:6]);}

PHP:1284
This is my second CodeGolf, and I wasn't really aiming for shortness as much as code mutability and matching the gaming criteria.
You can generate 4 sided dice as well as 6 sided.
Maybe later I will shorten it and make it a little more dynamic.
function draw_dice($numdice=1,$sides=4)
{
/* Verify acceptable parameters. */
if($sides<4){die("You must choose 4 sides or greater.");}
if($numdice<1){die("You must have at least one dice.");}
/* End verification */
$a=' ';
$b=' ';
$c=' ';
$d=' ';
$e=' ';
$f=' ';
$g=' ';
$h=' ';
$i=' ';
$j=' ';

switch($sides)
{
case $sides%2==0:
if($sides==4)
{
$ran=rand(1,$sides);
switch($ran)
{
case 1:
$e="o";
break;
case 2:
$a="o";
$j="o";
break;
case 3:
$b="o";
$g="o";
$j="o";
break;
case 4:
$a="o";
$c="o";
$g="o";
$j="o";
break;
}
echo "
";
echo " -
";
echo "| |
";
echo "|$a$b$c|
";
echo "| $d$e$f |
";
echo "|  $g$h$i$j  |
";
echo "---------
";
echo "
";

}

if($sides==6)
{
$ran=rand(1,$sides);
switch($ran)
{
case 1:
$e="o";
break;
case 2:
$a="o";
$i="o";
break;
case 3:
$a="o";
$i="o";
$e="o";
break;
case 4:
$a="o";
$c="o";
$g="o";
$i="o";
break;
case 5:
$a="o";
$c="o";
$g="o";
$i="o";
$e="o";
break;
case 6:
$a="o";
$c="o";
$d="o";
$f="o";
$g="o";
$i="o";
break;
}
echo "-----
";
echo "|$a$b$c|
";
echo "|$d$e$f|
";
echo "|$g$h$i|
";
echo "-----
";
}

if($sides!==4&&$sides!==6)
{
die("Only 4 and 6 sided are supported at this time.");
}

break;

case $sides%2==1:
die("Must have even number of sides.");
break;
}

}

draw_dice(1,4);

Output 4 sided:
    -
   | |
  |o o|
 |     |
|  o  o  |
---------

Output 6 sided:
-----
|o  |
| o |
|  o|
-----

JavaScript 220 bytes
r=(1+Math.random()*6|0).toString(2).split("").reverse();b=r[1];c=r[2];s=[[b|c,0,c],[b&c,1&r[0],b&c],[c,0,b|c]];"-----\n|"+s.map(function(v){return v.map(function(w){return w?"o":" "}).join("")}).join("|\n|")+"|\n-----";

PHP 5.4, 107 bytes
<?$r=rand(1,6);$d=[' ','o'];$o='+---+
|'.$d[$r>1].' '.$d[$r>3].'|
|'.$d[$r>5];echo$o.$d[$r%2].strrev($o);

102 bytes*
<?$r=rand(1,6);$d=' o';$o='+---+
|'.$d[$r>1].' '.$d[$r>3].'|
|'.$d[$r>5];echo$o.$d[$r%2].strrev($o);

**Unfortunately, the 102 byte version issues notices due to the casting of bool to int when indexing the string $d. Other than that, it works fine.*

The byte counts seem to be 105 and 100, respectively.

Ah, I must've accounted for the newlines.

Ruby , 134 132 119 118 117 112 111 chars,
My second golf in life. I've used magic numbers.
Any advises please?
r=?-*5+"
|"+((a=:ghklm[rand 6])?a.to_i(36).to_s(2).tr("10","o "):"    o").insert(3,"|
|")
$><<r+r[0,14].reverse

Outputs:
ice@distantstar ~/virt % ruby ./golf.rb
-----
|o o|
|   |
|o o|
-----
ice@distantstar ~/virt % ruby ./golf.rb
-----
|o o|
|o o|
|o o|
-----
ice@distantstar ~/virt % ruby ./golf.rb
-----
|   |
| o |
|   |
-----
ice@distantstar ~/virt %

Mathematica 166 161 146 143 chars
a="O  ";b=" O ";c="  O";d="   ";e="O O";RandomInteger@{1, 6}/.Thread@Rule[Range@6,{{d,b,d},{a,d,c},{a,b,c},{e,d,e},{e,b,e}, {e,e,e}}]//MatrixForm

Sample Output:

If the matrix braces offend, you may replace MatrixForm with TableForm in the code.

VimScript – 169 chararacters
Note that this is not pure Vim since Vim has no builtin random number generator. There are extensions that can be downloaded for it of course, but since I am a diehard Linux man, I thought, why not just rely on the shell environment instead.
Code
norm5a-^[YPo|   |^[YPP
let x=system('echo $RANDOM')%6+1
if x<2
norm jllro
el
norm lrolljj.k
if x>3
norm k.hjj
en
if x>2
norm h.k
en
if x>5
norm .l
en
if x>4
norm l.
en
en

Explanation

The first line generators the "box" that represents the die.
The second line fetches a random number from the environment and using modular arithmetic forces it to be a valid number for a dice.
The remaining lines move around the die face filling in the o 's. Note that this is meant to be optimized for the least number of characters, not the least number of movements (i.e. there would be faster ways in turns of keystrokes if I was doing it manually—doing the ifs all in my head).
As always, ^ is not a literal ^ but an indication of an escape sequence.

Testing
Change RANDOM to DICEVALUE, save the VimScript code into dice.vim, then run this shell script on it, giving as arguments whatever numbers you want to test:
#!/bin/sh
for DICEVALUE in $@; do
    export DICEVALUE
    vim -S dice.vim
done

SmileBASIC, 117 99 bytes
N=RND(6)B=N>2?"-"*5L!!N*5-B*2L!(N<<31)*4-(N>4)L!!N+B*2?"-"*5DEF L I?"|";MID$("   o o  ",I,3);"|
END

Output
Cheating version:
?""[RND(6)] (What it looks like in SmileBASIC's font)

Vyxal, 38 bytes
3`|% |%%`-3/ømvøm⁋»∧⁰¾×O↓»b7ẇ℅ƛ‛o $i;%

Try it Online!
=== Part 1: Construct the dice ===
         -         # Prepend...
3                  # Literal
         -         # Minuses to...
 `|% |%%`          # Literal
          3/       # Into 3 pieces
            ømvøm  # Quad palindromise
                 ⁋ # Newline joined
=== Part 2: Roll the dice ===
»...»             # Compressed base-2 integer containing bits for each
     b            # To bits
      7ẇ℅         # Choose a random group of 7
         ƛ     ;  # Map...
          ‛o $i   # o or space depending on if its truthy
                % # Format above with this

J, 58 55 52 bytes
?@6{' o|-'{~6 3 3(3,~3,2,.,.&2)"2@$#:@36b3igm68ktg7p
Attempt This Online!

6 3 3... $#:@36b3igm68ktg7p Generate all dice patterns from a single base 36 number containing all the bits.
(3,~3,2,.,.&2)"2 Add the frame integers.
' o|-'{~ Convert to ascii.
?@6{ Randomly choose one.

source: Stack Exchange

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

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

sort: votes


text:
Formatting numbers
Today computers use millions of bytes of memory, and decimal or hexadecimal notations get less and less informative.
Most human-readable formatting just display the number with the highest unit prefix. What about the rest?
I devised a notation that I use for myself, and since then, I'm often faced with re-implementing it in various languages. I thought I could share it, and that it make for a good case for code-golfing too.
The rules

The program is given an integer as its input. It can be taken from a decimal or hexadecimal representation in a text file and then parsed, or from the "system innards".
It should outputs a representation of that number somehow
The limits are the system's limit. For practical purposes, assume 64 bits unsigned, so that the maximum number is 0xFFFFFFFFFFFFFFFF, and the unit suffixes will be k (kibi), M (mebi), G (gibi), T (tebi), P (pebi), E (exbi).
zeros should be skipped. Example: 5G + 10k should be written 5G;10k, and not 5G;0M;10k;0
It frequently happens, e.g. for memory ranges, that a number is just one less than a number with a nicer representation. For instance, 0xffff would be displayed as 63k;1023, though it is 64k minus 1. An exclamation mark denotes this, so that 0xffff should be displayed as !64k.

Examples

0 : 0
1023: !1k
1024: 1k
1025: 1k;1
4096: 4k
0x100000 : 1M
0xFFFFF : !1M
0x20000f : 2M;15
0x80003c00 : 2G;15k
0xFFFFFFFFFFFFFFFF : !16E

For 32 bits users, use 0xFFFFFFFF, which is, as everybody knows, !4G.
And 128 bits users can go up to... wait that's big! Anyway, feel free...

Very similar on Stack Overflow: Code-Golf: Friendly Number Abbreviator.

Can an explanation mark occur in the middle of the sequence?

What about 0xFFFFE? Can/should we write !!1M?

Howard: I'd say that's 1023k;1022, then.

»or from the "system innards"« What exactly does that mean?

You write "0xfff should be displayed as !64M", I suppose you mean "0xffff should be displayed as !64k"

@Gzorg, how do you define behaviour for 0xFF0000FFFF? I.e. a case where -1 could be used in part of the solution, though not all of it.

Windows PowerShell, 207 214 226 230 247 271 319 339 360
$v=1PB*1KB
filter t{[Math]::Floor($n/$v)}$(,0*!($n=[Convert]::ToUInt64(($i="$input"),10+6*($i[1]-gt60)))
'EPTGMk'[0..5]|%{if($n%$v+1-eq$v){$v--
"!$(t)$_"
$n=0}if(t){"$(t)$_"
$n%=$v}$v/=1kb}
,$n*!!$n)-join';'

Test run:
./friendly2.ps1: PASS: '2047' -> '!2k'
./friendly2.ps1: PASS: '4096' -> '4k'
./friendly2.ps1: PASS: '0x80003c00' -> '2G;15k'
./friendly2.ps1: PASS: '2049' -> '2k;1'
./friendly2.ps1: PASS: '0x1' -> '1'
./friendly2.ps1: PASS: '4097' -> '4k;1'
./friendly2.ps1: PASS: '0xFFFFF' -> '!1M'
./friendly2.ps1: PASS: '0xa000' -> '40k'
./friendly2.ps1: PASS: '1022' -> '1022'
./friendly2.ps1: PASS: '0x100000' -> '1M'
./friendly2.ps1: PASS: '2048' -> '2k'
./friendly2.ps1: PASS: '0x20000f' -> '2M;15'
./friendly2.ps1: PASS: '0' -> '0'
./friendly2.ps1: PASS: '0x0' -> '0'
./friendly2.ps1: PASS: '1' -> '1'
./friendly2.ps1: PASS: '0x80aef3' -> '8M;43k;755'
./friendly2.ps1: PASS: '14636699861675008' -> '13P;1023M;27k'
./friendly2.ps1: PASS: '0xFFFFFFFFFFFFFFFe' -> '15E;1023P;1023T;1023G;1023M;1023k;1022'
./friendly2.ps1: PASS: '1023' -> '!1k'
./friendly2.ps1: PASS: '4095' -> '!4k'
./friendly2.ps1: PASS: '0xFFFFFFFFFFFFFFFF' -> '!16E'
./friendly2.ps1: PASS: '1025' -> '1k;1'
./friendly2.ps1: PASS: '1024' -> '1k'

+1 for a good list of test cases - however how about adding one more test case? I suggest 0xFF0000FFFF.

@asoundmove: Most of those were already present in the question anyway. I just made them into a script to automatically test my solution.

Haskell, 335 333 332
f 0=["0"]
f n=let l=mod n 1024;s=f$div(n+1)1024;in if l==1023 then "!":s else show l:s
g []=[]
g ((_,"0"):s)=g s
g ((_,"!"):s)=let(c,z):t=g s in(c,'!':z):t
g ((c,n):s)=(c,n):g s
h ('_',s)=';':s
h (c,s)=';':(s++[c])
r n=let x=tail$concatMap h$reverse$g$zip"_kMGTPE"$f$read n in if x=="" then "0" else x
main=do x<-getLine;return$r x

JavaScript, 461 452 423 269 267 247
function(n){for(k=1024,M=k*k,G=M*k,T=G*k,P=T*k,E=P*k,y='EPTGMk',r='';n;){for(i=-1,f=0;++i<6;)n==(v=eval(x=y[i]))-1?(r+='!1'+x,n=0,f=1):n>=v?(r+=Math.floor(n/v)+x+';',n%=v,f=1):0;f?0:(r+=n,n=0);}return r?r[l=r.length-1]==';'?r.substring(0,l):r:'0'}

Hey you could shorten that a fair bit (2+4+6+8 = 20 bytes) with G=M*k...

Ruby 1.9, 130 167 181 191 203 characters
n=eval gets
u=1023
x=n&u<u ?n<1??0:"":(n+=1;?!)
s=[]
6.downto(0){|i|a=1024**i;n/a>0&&s<<[n/a,"EPTGMk"[6-i]]*""&&n=n%a}
puts x+s*?;

Passes all testcases from Joey's answer.

Can you not save 1 more char with n+=1 to n++?

@asoundmove: Ruby doesn't have increment operators, so the shortest way to increment a variable by one is indeed a+=1.

Scala, 295 characters
object F extends App{type S=String;def f(l:BigInt,s:S,p:S,g:Int,q:Int):S={val j=l&1023;return if(l+g>0)f(l>>10,if((j+g<1024&&j+g-q>0)||l-q<0)";"+"!"*(g-q)+(j+g-q)+p(0)+s else s,p.tail,(j.toInt+g)/1024,0)else s};val x=readLine.split('x');print(f(BigInt(x.last,4+x.size*6),""," kMGTPE",1,1).tail)}

With some line breaks to aid readability (though not much):
object F extends App
{
    type S=String
    def f(l:BigInt,s:S,p:S,g:Int,q:Int):S=
    {
        val j=l&1023
        return if(l+g>0)f(l>>10,if((j+g<1024&&j+g-q>0)||l-q<0)";"+"!"*(g-q)+(j+g-q)+p(0)+s else s,p.tail,(j.toInt+g)/1024,0)else s
    }
    val x=readLine.split('x')
    print(f(BigInt(x.last,4+x.size*6),""," kMGTPE",1,1).tail)
}

C#, 302 323
Direct conversion of my PowerShell solution.
using System;class F{static void
Main(){var
s=Console.ReadLine();ulong
n=Convert.ToUInt64(s,s.IndexOf('x')==1?16:10),v=1L<<60,b;s=n<1?"0":"";foreach(var
x in "EPTGMk"){b=0;if(n%v==v-1){s+="!"+(n/--v)+x;n=0;}if(n/v>0){s=s+(n/v)+x;n%=v;b=1;}if(b>0&&n>0)s+=';';v/=1024;}if(n>0)s+=n;Console.Write(s);}}

Python, 138 chars
N=input()
M=1023
s='0'[N:]
if N&M==M:N+=1;s='!'
print s+';'.join('%d'%b+k for b,k in zip([N>>60-10*i&M for i in range(7)],'EPTGMk ')if b)

Wouldn't that output a trailing space?

@Joey: Yes, it does sometimes.  Add a .strip() for 8 more characters if you care.

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


text:
Morse code generator in sound
Inspired by the Morse code question, and the Twinkle Twinkle little star question, write a program to accept a letter and generate the morse code audio for that letter.

Shell script (2 characters): cw. Accepts a line from standard input. Before running, do sudo apt-get install cw.

What are the allowed sounds we can use? Would 1hz be allowed, despite being considerably lower than what a human can hear (and my speaker can produce)? What should the timing be?

Windows PowerShell, 200
Makes a dot 70 ms long. Accordingly, a dash is 210 ms and the gap between both is 70 ms as well.
[char[]](-split' ☺ ☺    ☺ ☺  ☺       ☺  ☺☺           ☺☺☺ ☺ ☺  ☺   ☺☺ ☺  ☺☺☺  ☺☺  ☺☺ ☺  ☺      ☺   ☺    ☺  ☺☺ ☺  ☺ ☺ ☺☺ ☺☺  ')[[char]"$input".ToUpper()-65]|%{[Console]::Beep(880,70+140*$_)
sleep -m 70}

Since this contains control characters, here's a hexdump:
000: 5B 63 68 61 72 5B 5D 5D │ 28 2D 73 70 6C 69 74 27  [char[]](-split'
010: 00 01 20 01 00 00 00 20 │ 01 00 01 00 20 01 00 00   ☺ ☺    ☺ ☺  ☺
020: 20 00 20 00 00 01 00 20 │ 01 01 00 20 00 00 00 00       ☺  ☺☺
030: 20 00 00 20 00 01 01 01 │ 20 01 00 01 20 00 01 00       ☺☺☺ ☺ ☺  ☺
040: 00 20 01 01 20 01 00 20 │ 01 01 01 20 00 01 01 00    ☺☺ ☺  ☺☺☺  ☺☺
050: 20 01 01 00 01 20 00 01 │ 00 20 00 00 00 20 01 20   ☺☺ ☺  ☺      ☺
060: 00 00 01 20 00 00 00 01 │ 20 00 01 01 20 01 00 00    ☺    ☺  ☺☺ ☺
070: 01 20 01 00 01 01 20 01 │ 01 00 00 27 29 5B 5B 63  ☺ ☺ ☺☺ ☺☺  ')[[c
080: 68 61 72 5D 22 24 69 6E │ 70 75 74 22 2E 54 6F 55  har]"$input".ToU
090: 70 70 65 72 28 29 2D 36 │ 35 5D 7C 25 7B 5B 43 6F  pper()-65]|%{[Co
0A0: 6E 73 6F 6C 65 5D 3A 3A │ 42 65 65 70 28 38 38 30  nsole]::Beep(880
0B0: 2C 37 30 2B 31 34 30 2A │ 24 5F 29 0A 73 6C 65 65  ,70+140*$_)◙slee
0C0: 70 20 2D 6D 20 37 30 7D │                          p -m 70}

I have tried several variants pf packing the data more tightly, but PowerShell is quite verbose in unpacking them again, so I don't gain much, sadly.

What the bloody hell is that?! Please 'splain how smileys make Morse code?

Character 1 in code page 437 is a control character, but has a glyph in the mapping table. This glyph is a smiley. When displaying control characters in that code page without interpreting them (e.g. by writing directly to video memory) it becomes said smiley. The relevant data is in the hex dump I provided.

Sure.
VB.NET, 235 223 221 218 210 209 208 209 characters

With the appropriate structures, it is 245 characters.
Requires Option Strict to be Off for the latest one.
For Each c In"sl lsss lsls lss s ssls lls ssss ss slll lsl slss ll ls lll slls llsl sls sss l ssl sssl sll lssl lsll llss".Split()(Asc(UCase(Console.ReadKey.KeyChar))-65)
Console.Beep(1E3,200-(c="l")*400)
Next

Recent edits:

Fixed the incorrect "b".
Changed 999 to 1E3 so I can finally have that perfect thousand ;-)
Used boolean->integer conversion to save 2 characters.

The task says »Write a program ...«. I only see a few statements that won't compile on their own. Adding the module and sub declarations brings this to 272.

Who cares? Those are an unfair handicap and add absolutely nothing to the functionality of the program. I believe (as is noted in all of my questions here on Code Golf/Challenges) that default language structure should be able to be omitted from submissions to level the playing field. If you disagree, so be it. All I see here is over-sensitive nitpicking, and although nitpicking is great on programming forums, that kind of goes too far.

As for handicap and nitpicking: You may have your opinion there, but unless a task specifically asks for a code snippet instead of a function or complete program then your answer is just wrong according to the task specification. It's fine when your own tasks use a different metric, but respect that not everyone else uses it for their tasks. There are languages that golf better than others. No handicap you use will change that; we've discussed that on Meta already a while ago.

@Joey: Using the Split() function would prevent me from saving a space after In so it comes to the same number of characters. Maybe it has been discussed on Meta, but really - this is the important part.

This was my first (serious) code golf question, so I was a little sloppy in my wording.  Seeing how important the ground rules are, I'll be sure to be more careful (exact) from now on.

Adding the extra boilerplate does add something to the functionality of the program: it adds the ability for people who don't know the language to test it without having to learn the syntax.

The encoding for B is wrong - you have lss (D = _ . .) - it should be lsss (B = _ . . .).

QBASIC (236 characters)
I count each newline as one character because QBasic seems to work fine without carriage returns, at least when running in DOSBox. Note that it only supports letters, not digits or punctuation.
INPUT Y$:C&=2^(26-ASC(Y$)MOD 32):A&=31313855AND C&:B&=60257815AND C&:M&=29932103:GOSUB S
IF A&OR B&THEN M&=34172681:GOSUB S
IF A&THEN M&=9538602:GOSUB S
IF A&AND B&THEN M&=66070:GOSUB S
END
S:SOUND 750,SGN(M&AND C&)*2+1:SOUND 0,1:RETURN

Ok, I have to admit having trouble figuring out how you pull the tones out of the numbers again. Could you elaborate a bit on how you do it?

@Joey: Added an explanation to my JScript.NET answer, which works the same way.

JScript .NET (174 characters)
A little-known programming language from Microsoft, it combines the (relative) terseness of JavaScript with the power of the .NET Common Language Runtime. Thanks minitech and Joey for Console.Beep.
This program accepts a single letter from standard input (A-Z or a-z only). It does not explicitly add intra-character pauses, but they do exist, at least on Windows 7.
morse.js
function S(a){K.Beep(750,!!(a&C)*99+50)}import System;var K=Console,C=1<<26-K.Read()%32,A=31313855&C,B=60257815&C;S(29932103);(A||B)&&S(34172681);A&&S(9538602);A&&B&&S(66070)

Compile with:

%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\jsc morse.js

Explanation
Six 32-bit integers, of which 26 bits are used in each, serve as lookup tables. Each bit in a table corresponds to a letter of the alphabet, bit 25 used for A and bit 0 used for Z.
C = 1 << (26 - (K.Read() % 32)),

Because Morse code is a variable-length code that uses between 1 and 4 symbols for each letter, the tables 31313855 (bit 1) and 60257815 (bit 0) can together represent one less than the length of each letter's code.
A = 31313855 & C,
B = 60257815 & C;

The program uses additional lookup tables to store the dots and dashes for each letter. Using logic expressions of A and B, it stops once it has sent the correct number of symbols to the sound card.
S(29932103);
(A || B) && S(34172681);
A && S(9538602);
A && B && S(66070);

In each of the four lookup tables above, a zero represents a dot; a one represents a dash. !! (logical "not-not") is used to normalize false to 0 and true to 1 (to compensate for the differing locations of bits within the integer). The multiplication and addition of this value causes a dot to be a 50 ms, 750 Hz tone and a dash to be a (50 + 99) = 149 ms tone.
function S(a) {
  K.Beep(750, !!(a & C) * 99 + 50)
}

Powershell, 184 120 bytes
for($d='0;?3,>5:.H7<1/9@E42-6B8CG='[$args[0][0]-65]-42;$d-1){[Console]::Beep(880,200*($d%2*3+1))
$d=$d-shr1
sleep -m 70}

Test script:
$f = {

for($d='0;?3,>5:.H7<1/9@E42-6B8CG='[$args[0][0]-65]-42;$d-1){[Console]::Beep(880,200*(($d%2)*3+1))
$d=$d-shr1
sleep -m 70}

}

&$f "A"
sleep -m 700
&$f "B"

I used a timing setup for beginers:

the dot duration is 200ms
the gap between elements is less then dot duration (70 ms)
the dash duration is 4 dot durations


text:
Bingo card generator
A Bingo card is five columns of five squares each, with the middle square designated "FREE".  Numbers cannot duplicate.
The five columns are populated with the following range of numbers:

B:1-15
I:16-30
N:31-45
G:46-60
O:61-75

In as few characters as possible, output a string that can be interpreted as a randomized Bingo card.
For example:

1,2,3,4,5,16,17,18,19,20,31,32,33,34,35,46,47,48,49,50,61,62,63,64,65

This example is not randomized so that I can show that column 1 is populated with 1,2,3,4,5.  Also note that the free space has not been given any special treatment because the front-end that interprets this string will skip it.
Another example would be:

1,16,31,46,61,2,17,32,47,62...

In this example, the output is by row instead of by column.
A third example might be:

01020304051617181920313233343546474849506162636465

This is the same output as the 1st example except in fixed length.

Yes!  That's it!  My idea is to come up with a list of 75 or more words and populate the card with SELECT * FROM List ORDER BY NEWID()

R, 38 bytes
cat(apply(matrix(1:75,,5),2,sample,5))

Try it online!
(another 7 years later...  )

PHP, 86
for($o=[];25>$i=count($o);){$n=rand(1,15)+($i-$i%5)*3;$o[$n]=$n;}echo implode(",",$o);

Welcome to PPCG, nice first answer c:

Thanks, I just noticed a bit too late that this question is 5 years old... xD Not sure if it matters though

join is an alias for ìmplode and you can put the assigment in the after loop. This will shorten your idea to for($o=[];25>$i=count($o);$o[$n]=$n)$n=rand(1,15)+($i-$i%5)*3;echo join(",",$o);

R, 63 51 50 49 45 bytes
Thanks to Billywob for ongoing suggestions and encouraging my competitive streak.
cat(sapply(split(n<-1:75,cut(n,5)),sample,5))

5 14 15 3 1 20 30 28 18 27 32 45 42 43 41 49 54 50 56 47 68 66 64 73 71

The vectorized approach I tried is a bit shorter.cat(sapply(list(15,16:30,31:45,46:60,61:75),sample,5)) Edit: never mind the printing, added cat instead

@Billywob Thanks, that's a great answer! I have since found one that's even shorter. (Not vectorized, unfortunately.)

Turns you can do even better: cat(sapply(split(1:75,ceiling(1:75/15)),sample,5)). Works by splitting the vector 1:75 into a list where each element is a vector of length 15 instead of using list() to pass objects to sapply.

Very nice! I had your solution posted for a few seconds, but then I figured out how to outgolf you by a single byte.

Hah! Even better. But I don't think you need the labels = FALSE option for cut. Because all that matters is that there are 5 repeating factors passed to the split function, regardless of names.

Well I'll be damned. Thanks! Together we have made the shortest code for the question (so far), a rare feat! Although, given that the question is about 5 years old, perhaps I shouldn't be surprised.

Windows PowerShell, 51 54
I'm not sure whether I understood your task correctly, though.
(0..4|%{($x=15*$_+1)..($x+14)|random -c 5})-join','

Sample outputs:
5,9,1,7,13,26,18,23,17,22,37,33,34,41,44,50,53,59,60,58,73,72,64,69,66
14,10,13,5,1,24,29,26,17,30,34,33,43,41,38,59,50,60,49,56,71,61,72,70,68
3,11,4,5,13,27,16,25,26,22,43,34,42,32,38,51,52,49,58,54,61,70,73,71,62
1,9,13,12,4,23,25,20,26,22,40,33,35,44,37,55,47,52,59,53,74,70,75,64,69
8,6,7,1,9,16,21,23,18,17,35,41,37,38,34,60,50,57,51,59,66,75,73,74,71
11,6,13,4,1,29,27,24,22,18,40,35,41,32,43,51,54,57,58,53,74,71,69,66,64

Ruby 1.9, 48 characters
$><<(0..4).map{|i|[*1..75][15*i,15].sample 5}*?,

PHP 106
<?$z=1;for($i=0;$i<5;$i++){for($j=0;$j<rand(1,5);$j++){$o[]=rand($z,$z+15);}$z+=15;}echo implode(",", $o);

I'm not sure I understood correctly the problem... Can you provide a more detailed explanation?

The output is incorrect. You always need to output all 25 squares :)

Vyxal, 11 bytes
75ɾ15ẇƛÞ℅5Ẏ

Try it Online!
75ɾ         # range(1, 75)
   15ẇ      # Cut into chunks of 15
      ƛ     # Over each
       Þ℅   # Shuffle
         5Ẏ # Get the first five items

Clojure - 52 chars
(map #(take 5(shuffle %))(partition 15(range 1 76)))

Example output (note that it provides the separate rows as sub-lists):
((4 1 12 10 2) (25 23 21 16 27) (39 33 45 44 43) (48 53 59 54 47) (73 71 61 64 63))

Python 2, 84 bytes
from random import*
print sum([sample(range(1+i*15,16+i*15),5)for i in range(5)],[])

If the output as list if lists is okay there is a 75 bytes solution:
from random import*
print[sample(range(1+i*15,16+i*15),5)for i in range(5)]

Japt, 12 bytes
75õ òF Ëá5 ö

Try it (or formatted as a Bingo card)


text:
Fill in the lakes, 2D
The one-dimensional version of this problem was pretty easy, so here's a harder 2D version.
You are given a 2D array of land heights on standard input, and you have to figure out where the lakes will form when it rains.  The height map is just a rectangular array of the numbers 0-9, inclusive.
8888888888
5664303498
6485322898
5675373666
7875555787

You must output the same array, replacing all locations that would be underwater with *.
8888888888
566*****98
6*85***898
5675*7*666
7875555787

Water can escape diagonally, so there would be no lake in this configuration:
888
838
388

shortest code wins.  Your code must handle sizes up to 80 wide and 24 high.
Three more examples:
77777    77777
75657    7*6*7
75757 => 7*7*7
77677    77677
77477    77477

599999    599999
933339    9****9
936639 => 9*66*9
935539    9*55*9
932109    9****9
999999    999999

88888888    88888888
84482288    8**8**88
84452233 => 8**5**33
84482288    8**8**88
88888888    88888888

Some more testcases would be nice, if possible (especially input you would consider an edge case).

Is trailing whitespace in the output lines allowed?

@hallvabo: no.  Why would you want to?

Keith: I had another solution where I padded the input lines to a fixed width, and saved some bytes in the algorithm. If I have to remove the padding for the output, this approach takes more bytes than my currently best solution.

Haskell, 258 characters
a§b|a<b='*'|1<3=a
z=[-1..1]
l m=zipWith(§)m$(iterate(b.q)$b(\_ _->'9'))!!(w*h)where
 w=length m`div`h
 h=length$lines m
 q d i=max$minimum[d!!(i+x+w*y)|x<-z,y<-z]
 b f=zipWith(\n->n`divMod`w¶f n)[0..]m
 (j,i)¶g|0<i&&i<w-2&&0<j&&j<h-1=g|1<3=id
main=interact l

Example run:
$> runhaskell 2638-Lakes2D.hs <<TEST
> 8888888888
> 5664303498
> 6485322898
> 5675373666
> 7875555787
> TEST
8888888888
566*****98
6*85***898
5675*7*666
7875555787

Passes all unit tests. No arbitrary limits on size.

Edit (281 → 258): don't test for stability, just iterate to the upper bound; stop passing constant argument m

Python, 483 491 characters
a=dict()
def s(n,x,y,R):
 R.add((x,y))
 r=range(-1,2)
 m=set([(x+i,y+j)for i in r for j in r if(i,j)!=(0,0)and(x+i,y+j)not in R])
 z=m-set(a.keys())
 if len(z)>0:return 1
 else:return sum(s(n,k[0],k[1],R)for k in[d for d in m-z if a[(d[0],d[1])]<=n])
i=[list(x)for x in input().strip().split('\n')]
h=len(i)
w=len(i[0])
e=range(0,w)
j=range(0,h)
for c in[(x,y)for x in e for y in j]:a[c]=int(i[c[1]][c[0]])
for y in j:print(''.join([('*',str(a[(x,y)]))[s(a[(x,y)],x,y,set())>0] for x in e]))

I'm pretty sure there's a better (and shorter) way of doing this

Mostly works, but I did have to replace input() with sys.stdin.read() and remove the trailing \n from my sample inputs.

@Keith Randall - sys.stdin.read() reads from a file right? I'm still rather new at Python.

sys.stdin.read() reads STanDard INput until EOF.  input() reads and evaluates one line of standard input.

Python, 478 471 characters
(Not including comments.  452 450 characters not including the imports.)
import sys,itertools
i=[list(x)for x in sys.stdin.read().strip().split('\n')]
h=len(i)
w=len(i[0])
n=h*w
b=n+1
e=range(h)
d=range(w)
# j is, at first, the adjancency matrix of the graph.
# The last vertex in j is the "drain" vertex.
j=[[[b,1][(t-r)**2+(v-c)**2<=1 and i[r][c]>=i[t][v]] for t in e for v in d]+[[b,1][max([r==0,r>h-2,c==0,c>w-2])]]for r in e for c in d]+[[0]*b]
r=range(b)
for k,l,m in itertools.product(r,repeat=3):
    # This is the Floyd-Warshall algorithm
    if j[l][k]+j[k][m]<j[l][m]:
        j[l][m]=j[l][k]+j[k][m]
# j is now the distance matrix for the graph.
for k in r:
    if j[k][-1]>n:
        # This means that vertex k is not connected to the "drain" vertex, and is therefore flooded.
        i[k/w][k-w*(k/w)]='*'
for r in e:print(''.join(i[r]))

The idea here is that I construct a directed graph where each grid cell has its own vertex (plus one additional "drain" vertex).  There is an edge in the graph from each higher valued cell to its neighboring lower valued cells, plus there is an edge from all exterior cells to the "drain" vertex.  I then use Floyd-Warshall to calculate which vertices are connected to the "drain" vertex; any vertices that are not connected will be flooded and are drawn with an asterisk.
I don't have much experience with condensing Python code, so there's probably a more succinct way I could have implemented this method.

Common Lisp, 833
(defun drains (terr dm a b)
  (cond
    ((= (aref dm a b) 1) t)
    ((= (aref dm a b) -1) nil)
    ((or (= a 0) (= b 0)
     (= a (1- (array-dimension terr 0)))
     (= b (1- (array-dimension terr 1)))) t)
    (t (loop for x from -1 to 1
       do (loop for y from 0 to 1
           do (if (and (or (> x 0) (> y 0))
                   (drains terr dm (+ a x) (+ b y))
                   (<= (aref terr (+ a x) (+ b y))
                   (aref terr a b)))
              (progn
                (setf (aref dm a b) 1)
                (return-from drains t)))))
    (setf (aref dm a b) -1)
    nil)))

(defun doit (terr)
  (let ((dm (make-array (array-dimensions terr))))
    (loop for x from 0 to (- (array-dimension terr 0) 1)
       do (loop for y from 0 to (- (array-dimension terr 1) 1)
         do (format t "~a"
            (if (drains terr dm x y)
                (aref terr x y)
                "*"))
         finally (format t "~%")))))

No attempt has been made to golf this, I just found the problem interesting.  Input is the 2D array of the map.  The solution checks each square to see if it "drains" -- a square drains if it is on the outer edge or if it is adjacent to an equal or lower height square that drains.  To keep from recursing endlessly, the code keeps a "drain map" (dm) where it stores the drainage status of squares that have already been determined.

Your described logic isn't quite right, as it doesn't handle the case with the island correctly.

Python, 246 chars
import os
a=list(os.read(0,2e3))
w=a.index('\n')+1
a+=' '*w
def f(p,t):
    if e<a[p]or p in t:return
    t[p]=1
    return'*'>a[p]or any(f(p+d,t)for d in(~w,-w,-w+1,-1,1,w-1,w,w+1))
z=0
for e in a:
    if(' '<e)*~-f(z,{}):a[z]='*'
    z+=1
print''.join(a[:~w])

The solution works by doing a DFS from each position to determine whether or not to fill.
If trailing whitespace on each line is allowed, it may be shortened by using w=80 and padding the input lines with whitespace to 80 chars.


text:
Shortest path for a chess knight
Your program should compute the number of moves it takes a chess knight to reach each square of the chess board.  The input will be two space-separated integers representing coordinates of the starting square (horizontal then vertical coordinate, 0-7 inclusive each).  Your program should output a number grid containing the minimum number of moves a chess knight needs to make to reach each square.
examples
input
0 0

output
03232345
34123434
21432345
32323434
23234345
34343454
43434545
54545456

input
3 1

output
21232123
32303232
21232123
34121432
23232323
32323234
43434343
34343434

Shortest code wins.

Ruby 1.9, 146 151 characters
g=(?9*8+".
")*8
r=->x,a=0{x<0||a<g[x].to_i&&(g[x]=a.to_s;[21,19,12,8].map{|i|r[x+i,a+1];r[x-i,a+1]})}
r[eval gets.split*?++"*10"]
puts g.tr(?.,"")

APL (Dyalog Classic), 55 bytes
{⍵⌊d⍴1+⌊/¨⌷∘⍵¨¨a/⍨¨Ö↓2=×/↑|∘.-⍨a←,⍳d}⍣≡0@(⊂⌽⎕)⊢9⍴⍨d←8 8

{⍵⌊d⍴1+⌊/¨⌷∘⍵¨¨a/⍨¨Ö↓2=×/↑|∘.-⍨a←,⍳d}⍣≡0@(⊂⌽⎕)⊢9⍴⍨d←8 8
                                       0@(⊂⌽⎕)⊢9⍴⍨d←8 8 ⍝ create an 8x8 grid of 9s with a 0 at the start position
                           ∘.-⍨a←,⍳d                    ⍝ all differences between coordinates
                     2=×/↑|                             ⍝ is 2 equal to the product of the absolute values?
               a/⍨¨Ö↓                                   ⍝ filter where true (finds knight moves)
          ⌷∘⍵¨¨                                         ⍝ index into the board
     1+⌊/¨                                              ⍝ 1 plus the minimum (finds minimum distance)
   d⍴                                                   ⍝ 8x8 reshape
 ⍵⌊                                                     ⍝ the minimum of the new and old moves
{                                   }⍣≡                 ⍝ apply until converged (minimum distances found)

Try it online!

Haskell, 255 236 231 229 bytes
import Data.List
k x y=unlines[[toEnum$findIndices(elem(i,j))(scanl(\s _->filter(\(z,w)->z`elem`n&&w`elem`n)$(\(a,b)->[(a+c,b+d)|(c,d)<-zip[1,1,-1,-1,-2,-2,2,2][2,-2,2,-2,1,-1,1,-1]])=<<s)[(x,y)]n)!!0+48|j<-n]|i<-n]where n=[0..7]

D:
This is my first attempt at golfing. Also somewhat new to Haskell.
Test suite:
import System.Environment

main :: IO ()
main = do
    args <- getArgs
    let readArgs = map read args
    let out = k (readArgs !! 0) (readArgs !! 1)
    putStr out

Welcome to the site! Good first golf. If you want some additional ideas for Haskell golfing, check out https://codegolf.stackexchange.com/questions/19255/tips-for-golfing-in-haskell

map(\(c,d)->...)$zip ... can be shortened to zipWith(\c d->...)....

Windows PowerShell, 178 183 188
filter f($n){if($d[($p=$_)]-gt$n){$d[$p]=$n
12,8,21,19|%{$p+$_
$p-$_}|f($n+1)}}$d=,0*20+(0..7|%{,9*8+0,0})+,0*20
$x,$y=-split$input
20+"$y$x"|f 0
2..9|%{-join$d[(10*$_).."$_`7"]}

Passes both test cases.

JavaScript, 426 408 bytes
for(a=[],i=0;i<8;i++){a[i]=[];for(j=0;j<8;j++)a[i][j]=99}m=[[2,1],[2,-1],
[-2,1],[-2,-1],[1,2],[-1,2],[1,-2],[-1,-2]];function s(f,g,e,b){b&&(a[f][g]=0);
for(var b=[],c=0;c<m.length;c++){var d=[f+m[c][0],g+m[c][1]];a[d[0]]&&
a[d[0]][d[1]]&&a[d[0]][d[1]]>e&&(a[d[0]][d[1]]=e,b.push(d))}for(c=0;c<b.length;c++)
s(b[c][0],b[c][1],e+1)}function _(f,g){s(g,f,1,1);for(e="",b=0;b<8;b++)e+=
a[b].join("")+"\n";return e}

JavaScript is not the most concise language out there... But my coding style is a little verbose too.
Usage: _(0, 0) etc.

Take out all those vars and save yourself tons of space...

@minitech: It's a recursive function so that messes everything up... Some vars could be removed though, thanks.

Convert some of your functions to arrow functions (ES6) to save bytes


text:
LED Numbers and Letters
The program must print the following block of text of LED numbers exactly.
+-----------------------------------------------------------------+
|                                                                 |
| 000   1 222 333 4 4 555 666 777 888 999 AAA B   CCC   D EEE FFF |
| 0 0   1   2   3 4 4 5   6     7 8 8 9 9 A A B   C     D E   F   |
| 0 0   1 222 333 444 555 666   7 888 999 AAA BBB C   DDD EEE FFF |
| 0 0   1 2     3   4   5 6 6   7 8 8   9 A A B B C   D D E   F   |
| 000   1 222 333   4 555 666   7 888 999 A A BBB CCC DDD EEE F   |
|                                                                 |
+-----------------------------------------------------------------+

Notice the 1-char padding inside the borders.
The trailing newlines, and the types of the newlines are not significant.
However, the whitespaces are the spaces you get when you press spacebars (ASCII 32).
Shortest code wins. Using data encoding (base64, gzip), or compressing with other Unicode characters is discouraged. You cannot use programs like cat or gzip since they are not programming languages.
The character count must be less than 600 to qualify.

There is m4 which is turing complete language, so this is still possible, and one char less than cat

I always object to problems that have the form "solve this instance of a problem" rather than "write a program to solve any problem in this class". And if we make it general it becomes very similar to Code Golf - Banner Generation.

Didn't notice it is taken on Stack Overflow

What do you mean by data encoding is discouraged?  We can't use an array of encodings, say of a bit mapping of the characters to print from?

This would have been far more interesting of a challenge if it had taken a number (hex? decimal?) on input and output it in that banner format.

I think [tag:kolmogorov-complexity] problems should be allowed to take auxiliary data for input, with the input length (in bytes) counted against the score.  This could reduce overhead in languages that don't handle string literals well, and make it so the program can focus on the data complexity itself.

Please answer mellamokb's question, because I want to ask the exact same thing. A bitmap is the most obvious approach.. is that why you discourage it?

because I don't want everyone to post solutions with full of Chinese characters like this. http://codegolf.stackexchange.com/questions/1682/an-old-irish-blessing/1692#1692 I mean, "data encoding" is defined as "creating a hard-coded data, and decoding the data. However, generating the data instead of hard-coding is not 'data encoding' I am talking about".

The obvious solution is to count length in bytes after encoding with UTF-8 rather than counting characters.

@Peter I think perhaps the byte/char count isn't what SHiNKiROU turned off by. maybe he just finds Asian characters annoying. Anyway, not allowing encoding to unicode is probably a good idea as it encourages us to find new solutions.

Golfscript, 142 137 chars
Unfortunately some of the characters are control codes, so I'm going to have to post a hexdump and a link rather than a direct copy of the source:
00000000  27 2b 27 3a 28 27 2d 27  36 35 2a 3a 5e 28 6e 27  |'+':('-'65*:^(n'|
00000010  7c 27 3a 29 27 20 27 3a  7c 36 34 2a 3a 40 27 20  ||':)' ':|64*:@' |
00000020  7c 0a 7c 20 27 3a 76 5b  27 77 12 5d 5b 3a 6b 6f  ||.| ':v['w.][:ko|
00000030  52 7f 7b 7e 2f 65 1f 6d  6c 27 7b 7d 2f 5d 3a 24  |R.{~/e.ml'{}/]:$|
00000040  2c 2c 7b 3a 78 3b 5b 27  60 40 50 20 00 10 2c 08  |,,{:x;['`@P ..,.|
00000050  1a 04 00 02 05 01 03 27  7b 7d 2f 5d 7b 24 78 3d  |.......'{}/]{$x=|
00000060  26 21 5b 34 38 78 2e 31  30 2f 37 2a 2b 2b 5d 7c  |&![48x.10/7*++]||
00000070  2b 3d 7d 25 33 2f 7d 25  7a 69 70 7b 7c 2a 7d 25  |+=}%3/}%zip{|*}%|
00000080  76 2a 76 40 29 6e 28 5e  28                       |v*v@)n(^(|

leds.gs
Note that all of the characters are 7-bit values and legal Unicode code points, so the number of characters is the same as the number of bytes in UTF-8.
Basically there are two hard-coded arrays. The first is a 15-element bitmap indicating which of the 7 segments control each grid cell. The second is the 7-segment encoding of the 16 characters. Then it's just a case of using bitwise and to work out which segments are turned on and doing some string manipulation.

Python, 216 chars
S=' '
E='|\n| '
H=B='+'+'-'*65+'+\n|'+S*65+E
X='%(x)X'
M=[X+S+S,S+S+X,X+S+X,X+X+X]
for i in range(5):
 for n in range(16):H+=M[0xcf33ed703ec2bbdefbb55fb3dcd7addf37557ab>>10*n+2*i&3]%{'x':n}+S
 H+=E
print H+B[-6::-1]

You can kill 2 chars by replacing X+X+X with X*3.

Then you can also replace the for-loops with exec("H+=M[0xcf33ed703ec2bbdefbb55fb3dcd7addf37557ab>>10*n+2*i&3]%{'x':n}+S;n+=1;"*16+"n=0;H+=E;i+=1;")*5 to save another 3 characters.

@JPvdMerwe OMFG, that's an amazing shrink for Python... is there any chance you could apply this same technique in JavaScript loops?

@WallyWest, I don't know JS well enough, but if you can duplicate a string by multiplying it with an int then you should be able to. Otherwise, it would be highly unlikely to be useful as you'd have to assign a string duplication function to a var.

Java, 302 characters
class A{public static void main(String[]a){String d="w$]m.k{%o?zS|[#!% \" $ :(L 0 @ p` ",s="";for(int y=0;y<9;y++){s+=y%8==0?"+-":"| ";for(int x=0;x<64;x++)s+=y%8==0?"-":y!=1&&y!=7&&((d.charAt(8+x%4+y*4)-32)&d.charAt(x/4))>0?(char)((x<40?48:55)+x/4):" ";s+=y%8==0?"+\n":"|\n";}System.out.println(s);}}

Expanded :
public class A {
    public static void main(String[] args) {
        String d = "w$]m.k{%o?zS|[#!% \" $ :(L 0 @ p` ", s = "";
        for (int y = 0; y < 9; y++) {
            s += y % 8 == 0 ? "+-" : "| ";
            for (int x = 0; x < 64; x++)
                s += y % 8 == 0 ? "-" :
                    y != 1 && y != 7 && ((d.charAt(8 + x % 4 + y * 4) - 32) & d.charAt(x / 4)) > 0 ?
                            (char) ((x < 40 ? 48 : 55) + x / 4) : " ";
            s += y % 8 == 0 ? "+\n" : "|\n";
        }
        System.out.println(s);
    }
}

The digits shapes are encoded in a byte with the following pattern:
  1 1 1
2       4
2       4
2       4
  8 8 8
16      32
16      32
16      32
  646464

e.g number 5 is 1|2|8|32|64 = 107
When outputting the text, each "pixel" (character) is set only if some "lines" of digits are enabled. For example, the upper-left character of a digit is set only if the line 1 or 2 are enabled. The lower-down character is set only if lines 32 or 64 are enabled.

For the sheer fun of it...
BrainFuck 611
Note: Can probably be golfed further.
++[------>+<]>.++.................................................................--.>++++++++++.>--[-->+++<]>-.[---->+<]>+.................................................................-[->++++<]>.>++++++++++.>--[-->+++<]>-.[---->+<]>+.[-->+++<]>...[--->++<]>...[-->+++<]>+.-[--->++<]>.[-->+++<]>++...--[--->++<]>.++[-->+++<]>...[--->++<]>--.++[-->+++<]>+.-[--->++<]>--.++[-->+++<]>+.-[--->++<]>--.-----[->++<]>-...--[--->++<]>--.-----[->++<]>...[-->+<]>+++++.----[->++<]>-...+[-->+<]>++++.----[->++<]>...[-->+<]>++++.---[->++<]>-...+[-->+<]>+++.[->++<]>+...-[-->+<]>.+[->++<]>.[-->+<]>-...+[->++<]>+...-[-->+<]>-...++[->++<]>.[-->+<]>--.++[->++<]>+...-[-->+<]>--.+++[->++<]>...[-->+<]>---.-[->++++<]>.>++++++++++.>--[-->+++<]>-.[---->+<]>+.[-->+++<]>.[--->++<]>.[-->+++<]>.[--->++<]>...[-->+++<]>+.-[--->++<]>...[-->+++<]>++.--[--->++<]>...++[-->+++<]>.[--->++<]>--.++[-->+++<]>+.-[--->++<]>--.++[-->+++<]>+.-[--->++<]>--.-----[->++<]>-.--[--->++<]>--...-----[->++<]>.[-->+<]>+++++.....----[->++<]>-.+[-->+<]>++++.----[->++<]>.[-->+<]>++++.----[->++<]>.[-->+<]>++++.---[->++<]>-.+[-->+<]>+++.---[->++<]>-.+[-->+<]>+++.[->++<]>+.-[-->+<]>.[->++<]>+.-[-->+<]>.+[->++<]>.[-->+<]>-...+[->++<]>+.-[-->+<]>-.....++[->++<]>.[-->+<]>--.++[->++<]>+.-[-->+<]>--...+++[->++<]>.[-->+<]>---...-[->++++<]>.>++++++++++.>--[-->+++<]>-.[---->+<]>+.[-->+++<]>.[--->++<]>.[-->+++<]>.[--->++<]>...[-->+++<]>+.-[--->++<]>.[-->+++<]>++...--[--->++<]>.++[-->+++<]>...[--->++<]>--.++[-->+++<]>+...-[--->++<]>--.-----[->++<]>-...--[--->++<]>--.-----[->++<]>...[-->+<]>+++++...----[->++<]>-.+[-->+<]>++++.----[->++<]>...[-->+<]>++++.---[->++<]>-...+[-->+<]>+++.[->++<]>+...-[-->+<]>.+[->++<]>...[-->+<]>-.+[->++<]>+.-[-->+<]>-...++[->++<]>...[-->+<]>--.++[->++<]>+...-[-->+<]>--.+++[->++<]>...[-->+<]>---.-[->++++<]>.>++++++++++.>--[-->+++<]>-.[---->+<]>+.[-->+++<]>.[--->++<]>.[-->+++<]>.[--->++<]>...[-->+++<]>+.-[--->++<]>.[-->+++<]>++.--[--->++<]>.....++[-->+++<]>.[--->++<]>--...++[-->+++<]>+.-[--->++<]>--...-----[->++<]>-.--[--->++<]>--.-----[->++<]>.[-->+<]>+++++.-----[->++<]>.[-->+<]>+++++...----[->++<]>-.+[-->+<]>++++.----[->++<]>.[-->+<]>++++.----[->++<]>.[-->+<]>++++...---[->++<]>-.+[-->+<]>+++.[->++<]>+.-[-->+<]>.[->++<]>+.-[-->+<]>.+[->++<]>.[-->+<]>-.+[->++<]>.[-->+<]>-.+[->++<]>+.-[-->+<]>-...++[->++<]>.[-->+<]>--.++[->++<]>.[-->+<]>--.++[->++<]>+.-[-->+<]>--...+++[->++<]>.[-->+<]>---...-[->++++<]>.>++++++++++.>--[-->+++<]>-.[---->+<]>+.[-->+++<]>...[--->++<]>...[-->+++<]>+.-[--->++<]>.[-->+++<]>++...--[--->++<]>.++[-->+++<]>...[--->++<]>--...++[-->+++<]>+.-[--->++<]>--.-----[->++<]>-...--[--->++<]>--.-----[->++<]>...[-->+<]>+++++...----[->++<]>-.+[-->+<]>++++.----[->++<]>...[-->+<]>++++.---[->++<]>-...+[-->+<]>+++.[->++<]>+.-[-->+<]>.[->++<]>+.-[-->+<]>.+[->++<]>...[-->+<]>-.+[->++<]>+...-[-->+<]>-.++[->++<]>...[-->+<]>--.++[->++<]>+...-[-->+<]>--.+++[->++<]>.[-->+<]>---...-[->++++<]>.>++++++++++.>--[-->+++<]>-.[---->+<]>+.................................................................-[->++++<]>.>++++++++++.+[->++++<]>-.++.................................................................--.

Scala, 267 characters, with bitwise encoding since everything else is worse.
val a="+"+"-"*65+"+"
(a+:(""+:BigInt("sbnatrnet3het8h2l21ala42h2hetrn2trn8trl2g8ha58laha4e5rhesbnatrn8",32).toString(2).grouped(64).map(x=>x.indices.map(i=>if(x(i)=='0')" "else"%X".format((i/4)%16)).mkString).toSeq:+"").map(s=>"|%65s|".format(s)):+a).foreach(println)

JavaScript 327 characters
It's the best I can do here...
_='console.log("?;%0*K , 77&A:!CCC!/!2!3KK 5!6J7@@ 9 H :!C! < *K4,!&A:BI!DD/ 2J3!4!5 6 6!7@@!H : I!D<0*!,!& :BICC DD>!|;|G?")J #====-$!!!!!!!%|G| 0&7@88 99H*0!1 222 333,4 555 666/>FF % 0!1:A B;G|$$$  < D E!F!%=--->D EEE F?+#####+@ 8G\\nH9 AIB CJ!  K 4';for(Y in $='KJIHG@?>=<;:/,*&%$#!')with(_.split($[Y]))_=join(pop());eval(_)

C (clang), 279 269 273 bytes
Too many printf()s; too many for loops.
(*P)()=printf;f(i,j,k,h){char*t="ckoOc;P5Z5UlolOoB0RXI=??_o7",u[66]={0};P("+%s+\n|%66c\n",memset(u,45,65),'|');for(h=0,i=5;i--;P("|\n"))for(P("| "),j=0;j<16;j++,P(" "),h=h>2?t++,0:h+2)for(k=3;k--;)P("X    XX XXXX"[k+((*t-48>>h)&3)*3]^88?" ":"%X",j);P("|%66c\n+%s+",'|',u);}

Try it online!

249 bytes

Perl, 486 characters, obviously not even trying hard.
sub p {print @_};p("+",'-'x65,"+\n");p('|',' 'x65,"|\n");
p("| 000   1 222 333 4 4 555 666 777 888 999 AAA B   CCC   D EEE FFF |\n");
p("| 0 0   1   2   3 4 4 5   6     7 8 8 9 9 A A B   C     D E   F   |\n");
p("| 0 0   1 222 333 444 555 666   7 888 999 AAA BBB C   DDD EEE FFF |\n");
p("| 0 0   1 2     3   4   5 6 6   7 8 8   9 A A B B C   D D E   F   |\n");
p("| 000   1 222 333   4 555 666   7 888 999 A A BBB CCC DDD EEE F   |\n");
p('|',' 'x65,"|\n");p("+",'-'x65,"+\n");


text:
Swapping heightmaps to depthmaps
Description
Your task is to output a 'depthmap' - that is, a heightmap of an object but not seen from its top but from its front.
For example, consider the following object as shown on the image. The height map is shown on the left. The corresponding depth map would be (as seen from standing at the arrow):
010
211   <- Depthmap
322

If you stand at the arrow, there are 3 cubes behind each other at the bottom left-hand point, 2 behind each other on the middle left-hand point, 0 at the top left-hand point etc.

Input
Input is a two dimensional array of any sizes (not necessarily square).
Output
Output is another two dimensional array which represents the depthmap. As you can deduce, its sizes are (height x width). In the image, it would be (3 x 3). Note that if the highest tower of cubes was 5, the depthmap would be an array of (5 x 3).
Winning condition
The shortest code wins.
Disallowed
All languages allowed, no explicit restrictions. (I don't know what you can come up with, but play fair please.)
Examples
Input:     Ouput:

5321       0001
1456       1012
2105       1112
           1212
           2222
           3323

Input:     Output:

22         01
13         12
00         22

Input:     Output:    (of the sample image)

232        010
210        211
101        322

Can you provide a sample input / output for the example image you posted?

Can you specify precisely what the depth-map is counting? I can't see a way to interpret the example given with the image consistently.

I hope the updated image is clearer.

@pimvdb: Nice puzzle. We encourage people to seek advice on the Puzzle Lab char or the Meta SandBox before posting. That way, these kinds of issues can be ironed out before your puzzle goes live. All of us have trouble producing a perfect specification, especially if the task is non trivial.

@dmckee: I'm terribly sorry. I honestly think I've included all information now though. Please tell me if there are any problems though.

Sorry, my stupidity. I was looking from the wrong axis.

@pimvdb: Don't fret it; it's not some kind of requirement. Just a service we provide for each other in hope of making the site a little better.

What's the correct output for an input of [[0 0] [0 0]]? The empty array []?

@Peter Taylor: Yes, its height is 0 so its dimensions are 0 x 2, which basically comes down to an empty array.

It would not be 323 the correct value for the 3rd line?

@Joey: Yes indeed, I'm sorry. I'm really going to discuss in the chat before posting next time... @Adilson de Almeida Jr: No, have a look at the picture. There are only two behind each other on the bottom right hand point if you stand at the arrow.

Well, the confusion regarding the last line might be that your definition of »depth map« is uncommon, I guess. Usually a depth map is the same as a height map, just seen from a specific camera – i.e. it tells the extension towards the viewpoint of a given scene (at least that's how 3D renderers treat it). What you have is essentially a how many blocks are behind each other in a given place. Not sure how to call it, though. An anlogy might be partially transparend glass blocks and the more you have of them behind each other, the darker the result gets – regardless of space between them.

@Joey: I wasn't aware of a real depthmap. I just altered the word as instead of the height of cubes you have to output the 'depth' of cubes. I admit it was perhaps not the best choice.

Don't worry. It's a fine task as it is now.

Golfscript, 42 chars
n%{n*~]}%zip:|[]*$),{:);n|{{)>},,}%}%-1%\;

results
$ golfscript 2657.gs < 2657-1.txt
0001
1012
1112
1212
2222
3323

$ golfscript 2657.gs < 2657-2.txt
01
12
22

$ golfscript 2657.gs < 2657-3.txt
010
211
322

Congratulations.

@pimvdb, thanks, but I think you should open it without accepting any answer for some time (may be one week).

Since the accepted answer can be changed any time again, where is the harm?

+100: 42 chars :-)

I refrained from looking at your solution until I'd written my own. Comparing them now, they're rather similar except that you save a ton of characters with the []*. Nice trick.

Ruby 1.9, 102 characters
f=$<.map{|g|[*g.chop.bytes]}
f.flatten.max.downto(49){|j|puts f.transpose.map{|n|n.count{|r|r>=j}}*""}

Passes all testcases.

Windows PowerShell, 108 111 114
(($i=@($input))-split''|sort)[-1]..1|%{$h=$_
-join(1..$i[0].Length|%{$x=$_-1
@($i|?{"$h"-le$_[$x]}).count})}

Passes all test cases.

Haskell, 118 characters
import List
p h=map(\c->transpose(lines h)>>=show.length.filter(>=c))['1'..maximum h]
main=interact$unlines.reverse.p

Edit (122 → 118): avoid filtering by only iterating to maximal height

Scala 236 characters
object D extends App{var(l,m,z)=(io.Source.stdin.getLines.toList,0,0);val a=Array.ofDim[Int](l.head.size,10);for(i<-l;(j,q)<-i.zipWithIndex;x<-1 to j-48){a(q)(x-1)+=1;m=List(m,j-48).max};for(i<-1 to m){for(j<-a){print(j(m-i))};println}}

With some formatting:
object Depthmap extends App
{
    var(l,m,z)=(io.Source.stdin.getLines.toList,0,0)
    val a=Array.ofDim[Int](l.head.size,10)
    for(i<-l;(j,q)<-i.zipWithIndex;x<-1 to j-48)
    {
        a(q)(x-1)+=1
        m=List(m,j-48).max
    }
    for(i<-1 to m)
    {
        for(j<-a)
        {
            print(j(m-i))
        }
        println
    }
}

I'm sure a better facility with for comprehensions would mean I could cut some characters from this.

JavaScript, 235 208 195 bytes
function _(b){for(e=Math.max.apply(0,b.join().split(",")),f=[],c=i=0;i<e;i++){for(
c=[],a=0;a<b[0].length;a++)for(d=c[a]=0;d<b.length;d++)b[d][a]>i&&c[a]++;f[e-i-1]
=c.join("")}return f.join("\n")}

Just for the record, this is the code I made up before posting the question. (Smallened now)

Haskell Version (Now optimized)
import Data.List
import Text.Parsec
import Text.Parsec.String

main= readFile"in.txt">>=(\t->either print(putStrLn.intercalate"\n".map(concatMap show).(\j->map (\n->(map(length.(filter(>=n)))(transpose$reverse j))) (reverse [1..(maximum$map maximum j)])))(parse(many1$many1 digit>>=(\x->newline>>(return$map(read.return)x)))""t))

Ungolfed version
import Data.List (foldl', transpose, intercalate)
import Text.Parsec
import Text.Parsec.String

-- Source:  http://codegolf.stackexchange.com/questions/2657/swapping-heightmaps-to-depthmaps

digitArray :: Parser [[Int]]
digitArray = many1 $ do xs <- many1 digit
                        optional newline
                        return $ map (read . return) xs

maxHeight :: Ord c => [[c]] -> c
maxHeight = maximum . (map maximum)

heightToDepth :: [[Int]] -> [[Int]]
heightToDepth ins = level (maxHeight ins)
        where level 0 = []
              level n = (map (length . (filter (>=n))) xs) : level (n-1)
              xs      = transpose $ reverse ins

lookNice xs = intercalate ['\n'] $ map (concatMap show) xs

main = do inText <- readFile "in.txt"
          case parse digitArray "" inText of
              Left err -> print err
              Right xs -> putStrLn $ lookNice $ heightToDepth xs

Long answers to [code-golf] questions are acceptable when the length arises from using unsuitable languages (say fortran 77), but you are still expected to make an attempt to golf them. Not even bothering to reduce your identifiers to single letter is failing to get into the spirit of the game, which I suspect is the cause of the downvotes.

Welcome to code golf!  Can you separate your golfed code from your ungolfed code, and put a character count in your post for your golfed code please?  Thanks!  It will make your post a little easier to read and is the general pattern we use.

The goal of code golf is to create the shortest code possible. Yours is rather verbose, so try harder!

Python, 117 chars
import sys
a=zip(*sys.stdin)[:-1]
n=int(max(map(max,a)))
while n:print''.join(`sum(e>=`n`for e in r)`for r in a);n-=1

Similar to Ventero's Ruby solution.

Uiua, 10 bytes
⇌⍉/+⬚0∵↯∶1

Try it online!
⇌⍉/+⬚0∵↯∶1    input: a matrix of numbers
        ∵↯∶1    replace each number with that many 1s repeated...
     ⬚0         ...filling the remaining space in the 3D array with zeros
   /+            sum layers element-wise
⇌⍉              transpose and reverse to put the result in correct orientation

APL (Dyalog Extended), 14 bytes
{⊖⍉+⌿⍵≥⍀⍳⌈/,⍵}

Try it online!
{⊖⍉+⌿⍵≥⍀⍳⌈/,⍵}    Monadic function:
             ⍵     Start with a 2D array ⍵.
          ⌈/,      Find the overall maximum value h.
         ⍳         Make the list 1...h
       ≥⍀          Make a ≥ table between that list and ⍵.
                   Now we have a 3D matrix where position [a,b,c]
                   represents whether ⍵[a,b] is at least c.
    +⌿             We sum along the outermost (first) dimension,
                   since that corresponds to a column of ⍵.
                   Now we have a 2D matrix where position [b,c]
                   represents how many values in column b of ⍵ are at least c.
  ⍉                Transpose so the heights are rows.
 ⊖                 Flip vertically.

Clojure, 102 bytes
#(for[h(range(apply max(flatten %))0 -1)](map(fn[w _](count(for[r % :when(>=(r w)h)]_)))(range)(% 0)))

Japt, 12 bytes
c rÔÆÕËè>X
w

Try all test cases
Outputting the rows in reversed order would save 2 bytes, taking input in column-major order would save 1 byte, doing both would (naturally) save 3 bytes
Explanation:
c rÔ          #Find the maximum height
    Æ         #For each number X in the range [0...max_height]:
     Õ        # Get the columns of the input
      Ë       # For each column:
       è>X    #  Count how many items are greater than X

w             #Reverse the output

Julia, 55 bytes
!a=[sum(a[:,j].>m-i) for i=1:(m=max(a...)),j=axes(a,2)]

Attempt This Online!


text:
The minimum fibonacci challenge!
Challenge

In this task you would be given an integer N (less than 106), find the minimum way in which you could sum to N using only Fibonacci numbers - this partition is called Zeckendorf representation.

You could use any Fibonacci number more than once and if there is more than one representation output any.
For example if the input is 67 then one possible output could be using the Fibonacci numbers 1,3,8,55 which is also the minimum number of Fibonacci numbers that could be used to get the sum 67.
The input N is given on a single line, the inputs are terminated by EOF.
Examples
Given in the format input: output
0: 0
47: 34+13
3788: 2584+987+144+55+13+5
1646: 1597+34+13+2
25347: 17711+6765+610+233+21+5+2
677: 610+55+8+3+1
343: 233+89+21
3434: 2584+610+233+5+2

Constraints

The number of inputs would not exceed 106 values.
Your program should not run more than 5 seconds for all inputs.
You can use any language of your choice.
Shortest solution wins!

"You could any Fibonacci number..." eh?  "The number of inputs would not exceed 10^6 values."  So we will never need to add more than 10^6 numbers together?  Do you mean the sum of the inputs would not exceed 10^6?

Spoilers: 1) The greedy algorithm (subtract largest Fibonacci number until input is zero) produces optimal solutions.  2) An optimal solution need not use a Fibonacci number twice (which follows from 1). 3) An optimal solution, for N <= 1000000, will have no more than 14 terms.

@Joey: More generally, the greedy algorithm decomposes positive integers into sums of distinct Fibonacci numbers such that consecutive Fibonacci numbers are not used (this is called Zeckendorf's theorem).

Spoiler 4: 29 terms of the Fibonacci sequence starting at 0 1 is sufficient.

@Nabb:Thanks for explaining the mathematics part.

"Your program should not run more than 5 seconds for all inputs." on what hardware? And how are you going to fund us to procure that hardware for testing?

Spoiler: Compute the Zeckendorf representation of a number and use that.

Relevant OEIS entry: A014417

Motorola 68000 assembly - 34 bytes
(GNU assembler syntax)
| short min_fib_partition(long N asm("%d2"), long *out asm("%a0"))
min_fib_partition:
    | Generate Fibonacci numbers on the stack (-1, 1, 0, 1, 1, 2, 3, ..., 1134903170).
    moveq #-1, %d0          | A = -1
    moveq #1, %d1           | B = 1
generate_loop:
    move.l %d0, -(%sp)      | Push A to the stack.
    exg.l %d0, %d1          | A' = B
    add.l %d0, %d1          | B' = A + B
    bvc.s generate_loop     | Stop when signed long overflows.

    | Go back up the stack, partitioning N using the greedy algorithm.
    moveq #0, %d0           | Initialize return value (number of terms).
subtract_loop:
    move.l (%sp)+, %d1      | Pop a Fibonacci number F off the stack.
    cmp.l %d1, %d2          | If N < F, continue to smaller Fibonacci number.
    blt.s subtract_loop
    addq.w #1, %d0          | Increment the term count.
    move.l %d1, (%a0)+      | Append F to the output array.
    sub.l %d1, %d2          | N -= F
    bne.s subtract_loop     | Continue if N has not yet reached zero.

    | Clear the stack by searching for that -1.
clear_stack_loop:
    tst.l (%sp)+
    bge clear_stack_loop

done:
    rts

36 → 34: Made Fibonacci generator stop on overflow rather than by counting, and fixed the 0 case so it outputs [0] rather than [].  However, passing a negative N crashes now.
The comment at the top is the C prototype of this function, using a language extension to identify what parameters go where (by default, they go on the stack).
My TI-89, with its 10MHz processor, takes 5 minutes to run this function on 1 – 1,000,000.
Although the machine code is (currently) fewer bytes than the GolfScript solution, it would probably be unfair to accept this as the shortest solution because:

Machine code is normally not counted as "source code".  Unlike source code, machine code usually has high symbol complexity and, more importantly, is unprintable.  See "Should executable binaries be considered a reasonable solution for code-golf?".
This solution only takes a single number as input, rather than multiple inputs.
This solution is a function, not a program.

If you have a TI-89/92/V200, you can download the full project here (outdated):
https://rapidshare.com/files/154945328/minfib.zip
Good luck coaxing RapidShare to give you the actual file.  Does anyone know of a good host for files this big?  8940 is an awful lot of bytes.

You could add a fourth point to the list: the solution doesn't give the output in the correct format :P I'm using 7 characters on string literals alone. BTW Do you return the list [0] for input 0? It looks to me that you return the empty list. It's an irritating special case.

@Peter Taylor: You're right, I missed that. I got terms and term counts mixed up.  I'll post a fix soon.

Golfscript, 43 chars
~]{:|': '[{0 1{|>!}{.@+}/;|1$-:|}do]'+'*n}%

I think this can probably be reduced by 3 to 5 chars with more effort. E.g. the unfold to then throw away the array feels wasteful.

Javascript (142)
Only handles single input at a time.  Because multi-line input is useless for JavaScript.
k=n=prompt(f=[a=b=1])|0;while((b=a+(a=b))<n)f.push(b);for(i=f.length,g=[];i--;)if(f[i]<=k)g.push(f[i]),k-=f[i];alert(n+': '+(n?g.join('+'):0))

http://jsfiddle.net/EqMXQ/

C, 244 characters
#define P printf
int f[30];int main(){f[28]=f[29]=1;int i=28;for(;i>0;--i)f[i-1]=f[i+1]+f[i];int x;while(scanf("%i",&x)!=-1){P(x?"%i: ":"0: 0\n",x);if(x>0){int i=0,a=0;while(x>0){while(f[i]>x)++i;if(a++)P("+");P("%i",f[i]);x-=f[i];}P("\n");}}}

With whitespace:
#define P printf
int f[30];
int main(){
    f[28] = f[29] = 1;
    int i = 28;
    for(; i > 0; --i) f[i-1] = f[i+1] + f[i];
    int x;
    while(scanf("%i",&x) != -1) {
        P(x ? "%i: " : "0: 0\n",x);
        if(x > 0) {
            int i = 0, a = 0;
            while(x > 0) {
                while(f[i] > x) ++i;
                if(a++) P("+");
                P("%i",f[i]);
                x -= f[i];
            }
            P("\n");
        }
    }
}

This program will read numbers out of standard input and write to standard output.

F# - 282 252 241 characters
let mutable d=int(stdin.ReadLine())
let q=d
let rec f x=if x<2 then 1 else f(x-2)+f(x-1)
let s x=
 d<-d-x
 x
printf"%d: %s"q (Core.string.Join("+",[for i in List.filter(fun x->x<d)[for i in 28..-1..0->f i]do if d-i>=0 then yield s i]))

Python - 183 Chars
Majority of the code is handling multiple inputs :(
f=lambda a,b,n:b>n and a or f(b,a+b,n)
g=lambda n:n>0and"%d+%s"%(f(0,1,n),g(n-f(0,1,n)))or""
try:
 while 1:
  n=input()
  print "%d: %s"%(n,n<1and"0"or g(n).strip("+"))
except:0

Can you put the n=input() at the end of the previous line?

I suppose so. :\

You can also save a character by removing the space after print

Mathematica 88
n = RandomInteger[10000, 10];

Print[k=#,For[i=99;l={},k>0,If[#<=k,k-=#;l~AppendTo~#]&@Fibonacci@i--];":"l~Row~"+"]&/@n

Example of output
3999: 2584+987+377+34+13+3+1
9226: 6765+1597+610+233+21
7225: 6765+377+55+21+5+2
9641: 6765+2584+233+55+3+1
6306: 4181+1597+377+144+5+2
4507: 4181+233+89+3+1
8848: 6765+1597+377+89+13+5+2
6263: 4181+1597+377+89+13+5+1
2034: 1597+377+55+5
6937: 6765+144+21+5+2

EXCEL : 89 chars in unique code:

Scala - 353 chars (100 chars for handling multiple inputs)
def h(m:Int){lazy val f={def g(a:Int,b:Int):Stream[Int]=a #:: g(b,a+b);g(0,1);};if(m==0)println(m+": "+m)else{var s=0;var t= f.takeWhile(_ <= m);var w="";while(s!= m){s+=t.last;w+=t.last+"+";t=t.takeWhile(_<=m-s);};println(m+": "+w.take(w.length-1))}}
Iterator.continually(Console.readLine).takeWhile(_ != "").foreach(line => h(Integer.parseInt(line)))

Iterator.continually(Console.readLine).takeWhile(_ != "").foreach(line => h(Integer.parseInt(line))) could be shortened to io.Source.stdin.getLines.foreach(l=>h(Integer.parseInt(l))) to save 40-ish characters.

Python 3 (170 chars)
while 1:
 s=input()
 if not s:break
 s=n=int(s);f=[1];t=[]
 while f[-1]<n:f+=[sum(f[-2:])]
 for i in f[::-1]:
  if s>=i:s-=i;t+=[i]
 print(n,'=','+'.join(map(str,t))or 0)

Multiline input, stop on empty line

C, 151 characters
main() {int i=1,n,f[30]={1,1};for(;i++<30;)f[i]=f[i-1]+f[i-2];while(scanf("%d",&n))for(i=30;;--i)if(f[i]<=n){printf("%d\n",f[i]);if(!(n-=f[i]))break;}}

readable version:
main() {
    int i=1,n,f[30]={1,1};
    for(;i++<30;)f[i]=f[i-1]+f[i-2];
    while(scanf("%d",&n))
        for(i=30;;--i)
            if(f[i]<=n) {
                printf("%d\n",f[i]);
                if (!(n-=f[i])) break;
            }
}

R, 170
x=scan();Filter(function(i)cat(unlist(Map(function(d)if(i>=d&&i){i<<-i-d;d},rev(lapply(Reduce(function(f,x)c(f[2],sum(f)),1:94,c(0,1),F,T),head,n=1)))),sep='+',fill=T),x)

Handles multiple inputs and cat's the result to STDOUT
> x=scan();Filter(function(i)cat(unlist(Map(function(d)if(i>=d&&i){i<<-i-d;d},rev(lapply(Reduce(function(f,x)c(f[2],sum(f)),1:94,c(0,1),F,T),head,n=1)))),sep='+',fill=T),x)
1: 100
2: 200
3: 300
4:
Read 3 items
89+8+3
144+55+1
233+55+8+3+1
numeric(0)
>

R (460 chars)
Another version using R.
Reading from file "input", output to the file "output"
d=as.list(as.integer(scan("input","",sep="\n")));n=36;f=rep(1,n);for(i in 3:n){f[i]=f[i-2]+f[i-1]};d2=lapply(d,function(x){a=vector("integer");i=1;while(x>0){id=which(f>=x)[1];if(x==f[id]){x=x-f[id];a[i]=f[id]}else{x=x-f[id-1];a[i]=f[id-1]}i=i+1}a});d=mapply(c,d,d2,SIMPLIFY=0);for(i in 1:length(d)){t=d[[i]];l=length(t);if(l==1){d[[i]]=paste(t[1],t[1],sep=": ")}else{d[[i]]=paste(t[1],": ",paste(t[2:l],collapse="+"),sep="")}}lapply(d,write,"output",append=1)

"input" example
0
47
3788
1646
25347
677
343
3434

"output" example
0: 0
47: 34+13
3788: 2584+987+144+55+13+5
1646: 1597+34+13+2
25347: 17711+6765+610+233+21+5+2
677: 610+55+8+3+1
343: 233+89+21
3434: 2584+610+233+5+2

More readable version:
dt <- as.list(as.integer(scan(file = "input", what = "", sep = "\n")))
n <- 36
fib <- rep(1, n)
for(i in 3:n){fib[i] <- fib[i-2] + fib[i-1]}
dt2 <- lapply(dt, function(x){answ <- vector(mode = "integer")
                               i <- 1
                               while(x > 0){
                                   idx <- which(fib>=x)[1]
                                   if(x == fib[idx]){
                                       x <- x - fib[idx]
                                       answ[i] <- fib[idx]
                                   }
                                   else {
                                       x <- x - fib[idx-1]
                                       answ[i] <- fib[idx-1]
                                   }
                                   i <- i + 1
                               }
                               answ})
dt <- mapply(FUN = c, dt, dt2, SIMPLIFY = FALSE)
for(i in 1:length(dt)){
    t1 <- dt[[i]]
    t1.len <- length(t1)
    if(t1.len == 1){
        dt[[i]] <- paste(t1[1], t1[1], sep=": ")
    } else {
        dt[[i]] <- paste(t1[1], ": ", paste(t1[2:t1.len], collapse = "+"), sep="")
    }
}
lapply(dt, write, "output", append=TRUE)

D (196 chars)
Run with rdmd --eval=…. This conveniently hides the boilerplate of import x, y, z; and void main() {…}:
int f(int i){return i-->1?f(i--)+f(i):i+2;}int n;foreach(x;std.stdio.stdin.byLine.map!(to!int))writeln(x,": ",x?n=x,reduce!((r,i)=>f(i)<=n?n-=f(i),r~="+"~f(i).text:r)("",29.iota.retro)[1..$]:"0")

Using Java
package org.mindcraft;

import java.util.Scanner;

public class Fibbo {
    public static void main(String[] args) {
    String number = null;
    int tmp, sum;
    int i = 1, j = 1;
    Scanner in = new Scanner(System.in);
    number = in.nextLine();
    String[] arr = number.split(" ");
    for (int it = 0; it < arr.length; it++) {
        tmp = Integer.parseInt(arr[it]);
        String value = tmp+" : ";
        while (tmp > 0) {
            i = 1;
            j = 1;
            for (int k = 0; k < 10000; k++) {
                sum = i + j;
                if (sum > tmp) {
                    //if (value == null) {
                    char ch=value.charAt(value.length()-2);
                    if(ch==':')
                    {
                        value = value+" "+ j + "";
                    } else {
                        value = value + " + " + j;
                    }

                    tmp = tmp - j;
                    break;
                }
                i = j;
                j = sum;
            }
        }
        System.out.println(value);
    }
}
}

This is code golf, so make sure to golf your answer.

Welcome to PPCG! As KSFT said, this is a [tag:code-golf] challenge. Please show some effort in answering this question in as few bytes of code as possible. At the very least, you can remove unnecessary whitespace and use single-letter class/method/variable names. After doing this, please also include the byte count in your answer.

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