text:
Determine if land is fully enclosed by fences
Imagine a two-dimensional array of boolean values, where the 0s represent squares of grass on a rectangular plot of land and the 1s represent fences.
Write a function that accepts the 2D array as an input and determines whether you can travel from any one area of grass to any other area of grass, using only north/east/west/south movements, without running into a fence.
If any area of grass in the array is fully enclosed by fences (meaning you can't travel N/E/W/S to reach every other area of grass in the array) the function should return false; otherwise, it should return true.
Below are two sample arrays you can use as inputs, although your function should be able to handle not just these but any 2D array of boolean values:
0 0 0 0 0
0 1 0 0 0
0 1 1 1 1
0 0 0 0 0
0 0 0 1 1

(should return true)

0 1 0 1 0
0 1 1 0 0
0 0 0 0 0
0 0 0 1 0
1 1 1 1 0

(should return false, since the middle 0 in the top row is fully enclosed)

Shortest working code wins.  I'll pick the winner after either a week has passed or there have been no new submissions within 24 hours.

Can you also forbid binary operators? I'd love to see what people would come up with.

I do believe this is very similar to a USACO problem from last year (2012/2013 season).  There are some huge test cases that can be accessed there...

Will the size of the array always be 5*5?

Is it also allowed to output '1' instead of 'true' and '0' instead of 'false'?

@ProgramFOX  Assume array could be any height, any width.  And sure, output anything boolean.

what about the 3X3 matrix 1 1 1; 1 0 1; 1 1 1?  There is one grass cell in the center.  Visually the grass cell in the center is fully enclosed by fences, but by your definition it is not.

Similar: http://codegolf.stackexchange.com/questions/801/is-this-figure-connected - test if all 0 are connected.

@jawns317: I've added some test cases (see "ungolved version"). Is that what you supposed to get?

Can you reformulate the task to: "Starting at a 0: Is there any 0 that you cannot reach?"?

What if the array is all 1s?  What should it return then?

Matlab 45
input('');c=bwconncomp(~ans,4);c.NumObjects<2

@jawns317 I don't see why this is the accepted answer. This isn't a function. The only other answer that isn't a function accepts from stdin. This one doesn't even do that.

Accepting standard input could be done as such input('');c=bwconncomp(~ans,4);c.NumObjects<2 This would make it 45 characters.

APL (39)
{∧/,⊃{⍺∨⊖⍵}/{⍵∨(∧\~⍵)∨⌽∧\⌽~⍵}¨s,⊖¨s←⊂⍵}

Usage:
      board1 board2
 0 0 0 0 0  0 1 0 1 0
 0 1 0 0 0  0 1 1 0 0
 0 1 1 1 1  0 0 0 0 0
 0 0 0 0 0  0 0 0 1 0
 0 0 0 1 1  1 1 1 1 0
      {∧/,⊃{⍺∨⊖⍵}/{⍵∨(∧\~⍵)∨⌽∧\⌽~⍵}¨s,⊖¨s←⊂⍵} ¨ board1 board2
1 0

The benefit of APL is that it looks so much like line noise that nobody wants to verify it is correct.

@Tim Anyone can download an interpreter to run it and check.

@Gareth Yeah, The comment was supposed to be tongue in cheek.

@Tim Oh sorry. Missed that. :-(

Mathematica, 60 58 chars
f=Max@MorphologicalComponents[1-#,CornerNeighbors->1>2]<2&

Usage:
f[{{0, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, {0, 1, 1, 1, 1}, {0, 0, 0, 0, 0}, {0, 0, 0, 1, 1}}]

True

f[{{0, 1, 0, 1, 0}, {0, 1, 1, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 1, 0}, {1, 1, 1, 1, 0}}]

False

Same length f=Max@WatershedComponents[Image@#,CornerNeighbors->1>2]<2&

Excel VBA, 305 215 Bytes
Yes, haha VBA, but the matrix nature of the problem suggets a practical solution in Excel might be interesting (Plus someone has already submitted an answer in my other languages!). Obviously VBA is not going to be the most succinct, but I think it's reasonable.
This flood fills from an arbitrary starting point then checks if any "grass" left
R is a worksheet range with 1's and 0's representing the fences and grass as defined in the problem. Bonus, the playing field doesn't have to be rectangular or even contiguous.
0 1 1 1 1
0   0 0 0 0
0 1 1 1 1

For example, would return False.  The zeros on the right can't be reached from the zeros on the left. The irregular field doesn't break it.
Function F(R)
L R, R.Find(0)
F = Not IsNumeric(R.Find(0))
End Function

Sub L(R, S As Range)
If S Or IsEmpty(S) Then Exit Sub
S = 1
L R, S.Offset(1, 0)
L R, S.Offset(-1, 0)
L R, S.Offset(0, 1)
L R, S.Offset(0, -1)
End Sub

Some notes on the golfing.
I think some chars could be trimmed if the requirement was inverted in regards to 1 and 0, but not enough to make it worth inverting.
VBA insists on a bunch a whitespace (a = b vs a=b), which doesn't help the char count.
S needs to be explicitly declared as a range. If it's left a variant, it turns into a range value rather than a range.
Maybe a better way to branch the flood? I couldn't come up with a loop that saved any chars to send it N/E/S/W
Edit: rethougt the base case on the flood fill, managed to trim quite a bit off by checking if it's at a base case after recursion rather than preventing the recursion.

Ruby, 202 198 193
a=$<.read.split('
').map(&:split)
f=->x,y{a[x][y]=1
[[-1,0],[1,0],[0,-1],[0,1]].map{|o|d,e=x+o[0],y+o[1]
f[d,e]if a[d]&&a[d][e]==?0}}
f[i=a.index{|x|x.index ?0},a[i].index(?0)]
p !(a.join=~/0/)

Does a flood-fill, then checks to see if there are any 0s left.

Damn! If I hadn't tested my code first I would have been faster. ;)

@Tim But then it would have been wrong! :P

PHP 147 202 177 165 149 bytes
EDIT I beat my gzip hack with a real php solution.
A little long.... input as a text string, no spaces, rows delimited by newlines. It flood fills with cs and then checks to see if there are any zeros left. In the loop I use exp as a crude upper bound on the number of iterations required. I take advantage of the symmetry to handle the duplicate cases in less code
function f($s){$r=strpos;$n=$r($s,'
');$s[$r($s,'0')]=c;for(;$i++<1<<$n;)$s=strrev(ereg_replace('0(.{'.$n.'})?c','c\1c',$s));return!1==$r($s,'0');}

Here is an ungolfed test case:
<?php
$s1="00000
01000
01111
00000
00011";

$s2="01010
01100
00000
00010
11110";

function f($s){
    $n=strpos($s,"\n");
    $s[strpos($s,'0')]=c;
    for(;$i<strlen($s);++$i)
        $s=strrev(ereg_replace(
            '0(.{'.$n.'})?c',
            'c\1c'
            ,$s));
    return!1===strpos($s,'0');
}

var_dump(f($s1));
var_dump(f($s2));

Python (219 bytes)
Definitely not the shortest, but it's my first try here, so I'm proud of it:
def f(n):
 m=[int(c) for c in n if c!='\n']
 for i in range(len(m)):
  if m[i]<1:m[i]=2;break
 g(m,n.find('\n'),i);return not 0in m
def g(n,w,i):
 for x in i-w,i-1,i+1,i+w:
  if 0<=x<len(n):
   if n[x]<1:n[x]=2;g(n,w,x)

It's input should be a String of 0s & 1s where rows are delimited by a newline (\n) character.
Example usage:
>>> f("00000\n01000\n01111\n00000\n00011")
True
>>> f("01010\n01100\n00000\n00010\n11110")
False

you can combine the last two if statements into one with and, I think it saves some chars

You can use tabulator as 8 spaces.

Python (196)
Standard flood filling.
g=raw_input()
m=g.find(' ')
g=g.replace(' ','')
V={}
def D(V,x):
 if V.get(x,0)or g[x]=='1':return
 V[x]=1;[D(V,x+i)for i in 1,-1,m,-m if 0<=x+i<len(g)]
D(V,g.find('0'))
print len(V)==g.count('0')

Takes the matrix through STDIN with each row separated by a single space. For example "01010 01100 00000 00010 11110".

Mathematica 53
f=Max@(Symbol@@Names@"I*`i*B*l")[Image[1-#],0,1>2]<2&

It calls the internal function Image`MorphologicalOperationsDump`imageBinaryLabel, which is similar to MorphologicalComponents.
f[{{0, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, {0, 1, 1, 1, 1}, {0, 0, 0, 0, 0}, {0, 0, 0, 1, 1}}]
f[{{0, 1, 0, 1, 0}, {0, 1, 1, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 1, 0}, {1, 1, 1, 1, 0}}]

True
False

PHP (286 chars)
Way too long, I probably went the long long way.
function D($a){$x=count($a);$y=count($a[0]);for($i=0;$i<$x;$i++)$a[$i][-1]=$a[$i][$y]=1;for($j=0;$j<$y;$j++)$a[-1][$j]=$a[$x][$j]=1;for($i=0;$i<$x;$i++){for($j=0;$j<$y;$j++){if($a[$i][$j]!=1){if($a[$i][$j-1]==1&&$a[$i][$j+1]==1&&$a[$i-1][$j]==1&&$a[$i+1][$j]==1)return 0;}}}return 1;}

Non-golfed:
function D($a)
{
$x=count($a);
$y=count($a[0]);
for ($i=0;$i<$x;$i++)
    $a[$i][-1]=$a[$i][$y]=1;
for ($j=0;$j<$y;$j++)
    $a[-1][$j]=$a[$x][$j]=1;
for ($i=0;$i<$x;$i++)
{
    for ($j=0;$j<$y;$j++)
    {
        if ($a[$i][$j] != 1)
        {
            if ($a[$i][$j-1] == 1 && $a[$i][$j+1] == 1 && $a[$i-1][$j] == 1 && $a[$i+1][$j] == 1)
                return 0;
        }
    }
}
return 1;
}

This isn't correct. It only checks to see if there are no single zeros which are surrounded by ones. There are more complicated ways to wall off zeroes.

Of course you are right. I was looking for another way to solve this without floodfills, I guess my search continues!

It is just a graph reachability problem, and floodfill  in this case is basically floyd-warshall without explicitly creating or representing the reachability graph. You could try to extract the graph and do the transitive closure yourself, but my guess is it will be longer.

C#, 235 Bytes
int[][]D;int w,h,n;bool Q(int x,int y){var r=x>=0&&x<w&&y>=0&&y<h&&(D[x][y]++==0);if(r){Q(x-1,y);Q(x+1,y);Q(x,y+1);Q(x,y-1);}return r;}
bool P(int[][]B){D=B;w=D[0].Length;h=D.Length; for(int i=0;i<w*h;i++)if(Q(i%w,i/w))n++;return n==1;}

It tries to flood fill every cell in the board, it it makes only one flood fill returns true.
bool R( int x, int y)
{
    var r = (x >= 0 && x < w && y >= 0 && y < h && D[x, y]++ == 0);
    if (r)
    {
        R(x-1, y);
        R(x+1, y);
        R(x, y+1);
        R(x, y-1);
    }
    return r;
}

public bool Do()
{
    D = Board1;
    w = D.GetLength(0);
    h = D.GetLength(1);
    for (int x = 0; x < w; x++) for (int y = 0; y< h; y++) if (R(x, y)) n++;
    return n == 1;
}

Python 2.X + 3.X: 335 chararcters
Golfed:
def f(n):
 x,y=0,0
 z=lambda x,y:y<len(n)and x<len(n[0])and n[x][y]!=1
 while not z(x,y):
  y+=1
  if y==len(n):
   y=0
   x+=1
  if x==len(n[0]):
   return False
 t=set([(x,y)])
 v=set()
 while t:
  (x,y)=t.pop()
  v|=set([(x,y)])
  if z(x+1,y):
   t|=set([(x+1, y)])
  if z(x,y+1):
   t|=set([(x, y+1)])
 return len(v)+sum(map(sum,n))==len(n)*len(n[0])

Ungolfed:
def f(n):
    """In the following filed, starting from a 0: is it possible to
       get to every other 0?

        >>> f([[0,0,0,0,0],\
               [0,1,0,0,0],\
               [0,1,1,1,1],\
               [0,0,0,0,0],\
               [0,0,0,1,1]])
        True
        >>> f([[0,1,0,1,0],\
               [0,1,1,0,0],\
               [0,0,0,0,0],\
               [0,0,0,1,0],\
               [1,1,1,1,0]])
        False
        >>> f([[1,1,1,1,1],\
               [1,1,1,1,1],\
               [1,1,1,1,1],\
               [1,1,1,1,1],\
               [1,1,1,1,1]])
        False
        >>> f([[1,1,1,1,1],\
               [1,1,1,1,1],\
               [1,1,1,1,1],\
               [1,0,1,1,1],\
               [1,1,1,1,1]])
        True
        >>> f([[1,1,1,1,1],\
               [1,1,1,1,1],\
               [0,1,1,1,1],\
               [1,0,1,1,1],\
               [1,1,0,1,1]])
        False
        >>> f([[1,1,1,1,1],\
               [1,1,1,1,1],\
               [1,1,1,1,1],\
               [1,1,1,1,1],\
               [1,1,1,1,0]])
        True
    """
    x, y = 0,0
    isValid = lambda x,y: y<len(n) and x<len(n[0]) and n[x][y] != 1
    for i in range(len(n)*len(n[0])):
        x = i%len(n)
        y = i/len(n)
        if isValid(x,y):
            break

    while not isValid(x,y):
        y += 1
        if y == len(n):
            y = 0
            x += 1
        if x == len(n[0]):
            return False # Problem is not clearly defined here
    toGo=set([(x,y)])
    visited=set()
    while toGo:
        (x,y) = toGo.pop()
        visited |= set([(x,y)])
        if isValid(x+1,y):
            toGo |= set([(x+1, y)])
        if isValid(x,y+1):
            toGo |= set([(x, y+1)])
    return len(visited)+sum(map(sum,n)) == len(n)*len(n[0])

if __name__ == "__main__":
    import doctest
    doctest.testmod()

Could you move the golfed version to to the top? Some people have a user script for this site which counts the characters in the first block of code.

@Gareth: Done..


text:
Creating a catalogue index
You have a program which creates an index for a catalogue.  The last step is missing: it must find and consolidate page ranges within the list of pages for each entry.
Each entry is currently an array of unique integers in order, e.g:
[18,19,20,21,22,47,56,57,62,67,68,69,70]

Write a function which returns a consolidated array of ranges and individual pages as appropriate.
Individual pages can be converted to strings or remain as integers.  Either of these would be valid results from the example input:
["18-22",47,"56-57",62,"67-70"] // valid
["18-22","47","56-57","62","67-70"] // valid

How are you going to measure 'fastest-code'? The trivial implementation is O(n) already, and I don't see a way to make it less than O(n), because you have to process the entire list anyway.

Perhaps better suited for golfing?

I second the golfing idea.

Yes fair comment.  An implementation of this might need to be run thousands of times for a large or broad-range catalogue, but I suppose it wouldn't be possible to decrease the complexity of processing each entry.

@TomDudman I gues for a few thousand entries, all but the most horrible implementations will work very quickly (you could post a test set).

-1 since you already accepted an answer even though you don't have an objective winning criterion to distinguish answers.

I guess OP is just looking for a code.

I’m voting to close this question it's tagged [tag:fastest-code] but is missing details about the specs of the computer on which answers are timed etc

In JavaScript,
function catalogue(arr) {
    if (!arr.length) return [];
    for (var cat = [], first, prev = first = arr[0], i = 1, l = arr.length; i <= l; ++i) {
        i === l || prev + 1 !== arr[i]
            ? (cat.push(first + (first === prev ? "" : "-" + prev)), prev = first = arr[i])
            : ++prev;
    }
    return cat;
}
catalogue([18, 19, 20, 21, 22, 47, 56, 57, 62, 67, 68, 69, 70]);
    // ["18-22","47","56-57","62","67-70"]

Minified version (153 characters):
function f(b){if(!b.length)return[];for(var g=[],e,c=e=b[0],d=1,h=b.length;d<=h;++d)d===h||c+1!==b[d]?(g.push(e+(e===c?"":"-"+c)),c=e=b[d]):++c;return g}

For me, this is a very elegant, human-readable, self-contained function which can be easily translated into other languages.

Mathematica, 74
Assuming that replacing [] with {} in I/O is allowed:
t=ToString;f=Split[#,#2<#+2&]/.{s_Integer,___,e_}:>t@s<>"-"<>t@e/.{x_}:>x&

f[{18, 19, 20, 21, 22, 47, 56, 57, 62, 67, 68, 69, 70}]
{"18-22", 47, "56-57", 62, "67-70"}

The Split part should be quite fast (because someone else probably spent a lot of time optimizing) - the pattern matching part might be a bit slower in comparison. If speed is the main criterium, then there will be other ways to process the Split result (let´s see how the Q develops). For an input of 10^6 entries this takes about 2.7s on my (average) laptop (2.2GHz i7), of which about 1s goes to Split.

Javascript 271 bytes
A relatively simple application of reduce. If we are going to golf it, it minifies down to 271 chars.
Minified:
function f(a){function d(a,b,c){c=(a+"").split("-");return 2>c.length?a+1==b?[!1,a+"-"+b]:[!0,b]:+c.pop()+1==b?[!1,c[0]+"-"+b]:[!0,b]}return a.reduce(function(a,b,c,e){if("number"==typeof a)return[d(a,b)[1]];e=a.length-1;c=d(a[e],b);c[0]?a[e+1]=c[1]:a[e]=c[1];return a})}

Unminified
function g(p,c,i){
    i=(p+"").split("-");
    if(i.length==1) return (p+1==c)?[false,p+"-"+c]:[true,c];
    return ((+i[i.length-1])+1==c)?[false,i[0]+"-"+c]:[true,c];
}

function f(arr){
return arr.reduce(function(p,c,i){
    if ( typeof p =="number") {
        return [g(p,c)[1]];
    }
    else {
        i=g(p[p.length-1],c);
        if (i[0])
            p[p.length]=i[1];
        else
            p[p.length-1]=i[1];
        return p;
    }
});
}
alert(JSON.stringify(f([18,19,20,21,22,47,56,57,62,67,68,69,70])));

Haskell
module Pages (ranges) where

ranges =
  let f (a, b) | a == b = show a
               | a /= b = show a ++ "-" ++ show b
  in map f . ranges'

ranges' [] = []
ranges' (h:t) =
  unpack (range h h t)
  where unpack (t, l) = t : ranges' l

range :: Int -> Int -> [Int] -> ((Int, Int), [Int])
range a b [] = ((a, b), [])
range a b l@(h:t) | b+1 == h = range a h t
                  | otherwise = ((a, b), l)

source: Stack Exchange

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

sort: votes


text:
ROT13 one ASCII character
This kind of question has been asked before, but I wanted to make it more specific. The linked question asks to read from stdin and rot13 the input. I don't want the disadvantage of I/O code that differs a lot for each language in length.
The challenge:

Write a function that will ROT13 (wiki link) one char (as defined by the ASCII table).
No built-in ROT13 functionality allowed.

Shortest code wins.

You can use this kind of C-family loop to test your function:
for (int i = '!'; i <= '~'; ++i)
{
    char c = (char) i;
    System.out.println(c + "   ->   " + f(c));
}

@Howard: I linked that question myself. But that is different. Here the task is to rotate only one char.

The difference is minor only - almost all answers from the other question can be user with litte modifications.

@Howard: The most important difference is that I don't want the I/O code here. Just the plain algorithm.

In my opinion changing I/O doesn't justify a new question in this case.

C (77 64 chars)
char f(char c){return(c>64&&c<91)?65+(c-52)%26:(c>96&&c<123)?97+(c-84)%26:c;}
char f(char c){return(isalpha(c))?65+(c&32)+(c-52-(c&32))%26:c;}

I came up with this in Java (81 chars):
char f(char c){return Character.isLetter(c)?(char)((((c&95)-52)%26+65)|c&32):c;}

Demo here: http://ideone.com/ItT7IM

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


text:
Random literal number
I took inspiration from a challenge I did some years ago in a programming competition.
Your goal is to write a function that generates a random integer number between 0 and 150 (included), and then prints it in actual words. For example, 139 would be printed as onehundredthirtynine.
Rules:

You cannot use any external resource, nor any library that will perform the conversion.
The shortest answer will win.

Good luck!

With or without spaces?

Without spaces, as you can see in the example! :)

... Damn, I actually searched for it. Didn't use proper keywords :/

Don't worry, neither I found it easily. (I knew another question which links to that one.)

Lua
print"four"

Highly optimized and golfed xkcd's random number generator
An actual solution, 380
x=math.random(0,150)m=math.floor print(x==0 and"zero"or((x>99 and"onehundred"or"")..(({"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"})[x%100-9]or({[0]="",nil,"twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety"})[m(x/10)%10]..({[0]="","one","two","three","four","five","six","seven","eight","nine"})[x%10])))

print"un" in French. How about just "un"?

PHP has barewords. 2 characters in PHP

still an invalid answer. This isn't [tag:code-trolling].

Besides, Dilbert did such 6 years earlier.


text:
Convert a decimal to a fraction
Write a program that converts a decimal to a mixed, simplified fraction.
Sample input:
5.2

Sample output:
5 + (1/5)

The code with the shortest length in bytes wins.

Easy: 1.2345 = 12345/10000. You give me the precision & I'll give you the fraction!

Do you mean simplified fractions?

i meant mixed fractions

basically: find how many spaces the decimal goes beyond the decimal point (e.g. 2.357 is 3 digits after decimal), then turn it into improper, unsimplified: 2357/1000 and then, have a list of primes, starting at lowest, try to divide both numbers by it without remainder, then try it on that until at least one of the numbers is a prime and the other is not divisible by that number, and you're done

@CrowdStar: Does the fractional part need to be simplified?

Yep, it has to be. @Gelatin

5.2 != 5+1/2...

@Markasoftware: That won't necessarily work (the factor might not be prime) and it could take a long time. The best way (AFAIK) is to find the gcd of both (using the Euclidean algorithm) and divide through.

Is there a convention for negative mixed fractions? What about proper fractions?: 0+3/7 or simply 3/7 ?

@Gelatin I'm pretty sure all whole numbers which are greater than 1 and are not prime have at least one factor that is prime.

@Markasoftware: I guess it would work if you did it more than once.

Ruby, 43
y=gets.to_r;puts"#{y.to_i} + (#{y-y.to_i})"

Pretty straightforward.

Interesting solution. I'm honestly surprised you can make such short program with correct output format.

Ruby has a lot of Lispy features and the Rational class is probably one of the lesser-known ones. However, if the input is a float you're liable to get something like "2 + (1499999999999999/5000000000000000)"

python 3, 84
from fractions import*
a,b=input().split(".")
print("%s + (%s)"%(a,Fraction("."+b)))

Doesn't return the output in correct format. + should be returned (but otherwise, it's close to expected format).

@GlitchMr Edited the format.

Also, there are parens. Dunno why, but the OP put them.

@GlitchMr Added those creepy parens. Now the code size raised to 84 :-(

81 bytes using f-string, code

GolfScript, 40
'.'/~'+'\.~.@,10\?.@{.@\%.}do;:d/\d/'/'@

Requires no line terminator in the input. Can probably be golfed further.

Golf-Basic 84, 32 characters
Executed from a TI-84 calculator
i`A:floor(A)→B:A-B→A:d`Bd`A►Frac

Mathematica 73
No cigar this time. Numerator, Denominator and Rationalize are big words.
f@x_:=(Row@{⌊#⌋,"+",Numerator@#~Mod~(d=Denominator@#)/d})&[Rationalize@x]

Example
f[23.872]

GTB, 28
`A:floor(A)→B:A-B→A~B~A►Frac

The source code for your compiler cannot be run since iX2Web is not available. The link in your site is bad as well.

Perl 6 (53 bytes)
Does the output in right, expected format. Would be way shorter if output in invalid format would be allowed. This gets a number, converts it to rational. nude method returns denominator and numerator (there are separate denominator and numerator methods, but they are crazily long.
[] is a reduce operator which takes operator between square brackets, and in this case, I use it to shorten the code (so I wouldn't have to specify both array elements, because they are already in correct order (but if they wouldn't, there are R operators (like R/, R%, Rdiv, and Rmod) that reverse the order of arguments for operator)). {} in double quotes puts the result of code in string (like #{} in Ruby).
my \ is declaration of sigilless variable. In this case it doesn't save characters, but it doesn't waste them either, so why not use it. I could have used my@, and it would use identical number of characters.
my \n=get.Rat.nude;say "{[div] n} + ({[%] n}/{n[1]})"

Sample output (just to show the correct format):
~ $ perl6 -e 'my \n=get.Rat.nude;say "{[div] n} + ({[%] n}/{n[1]})"'
42.42
42 + (21/50)

If negative number support is needed, this would work (2 bytes more).
~ $ perl6 -e 'my \n=get.Rat.nude;say "{[div] n} + ({[mod] n}/{n[1]})"'
-42.42
-42 + (-21/50)

R, several lines
How about the way they tought us at grammar school?
f=function(s){
  gcd=function(a,b)if(!b)a else gcd(b,a%%b)
  a=strsplit(s,'\\.')[[1]]
  p=10^nchar(a[2])
  x=strtoi(a[2])
  d=gcd(x,p);
  cat(a[1]," + (",x/d,"/",p/d,")",sep="");
}

Vaguely: works for positive decimals with finite decimal fraction.
> f("23.872")
23 + (109/125)

Input must be a string matching "[0-9]+\.[0-9]+" regular expression.

 Haskell
Isn't pretty, but whatever
import Data.Ratio
main=let r '%'='/';r c=c in interact$(\(x,y)->show x++" + "++map r(show$approxRational y 1e-9)).properFraction.read

Vyxal, 20 19 bytes
I₌I-ƒJ`% + (%/%)`$%

Try it Online!
It's convoluted because of the handling of the output format
Explained (old)
:I₌₴-ƒ\/j`...`$%,
:I                # int(input)
  ₌₴-             # print(top, end=""), input - int(input) [gets the fractional part]
     ƒ            # Turn the decimal into a simplified fraction
      \/j         # Join that on "/"
         `...`    # The string " + (%)" -> this will be used for formatting the output
              $%, # perform string formatting and output the fraction part

Pyth, 34 bytes
phAcQ\.s[" + ("/sHKisHJ*TlH\//JK\)

Not that proud of this but that output format was getting to my head
Try it online!

Vyxal, 34 bitsv2, 4.25 bytes
1ḋ\+j

Does divmod with 1 and then joins on +. Outputs a+b/c.
Try it Online!
If the IO format was a bit looser
2 bytes
1ḋ

Does divmod with 1. Outputs ⟨ a | b/c ⟩
Try it Online!

Racket, 134 bytes
((λ(f[d(denominator f)][n(numerator f)])(printf"~a + (~a)"(quotient n d)(rationalize(/(modulo n d)d)(/ 1 d))))(inexact->exact(read)))

Try it online!

Explanation
Racket natively supports fractions. Fractions are referred to as "exact number" as the values of fraction aren't affected by IEEE floating-point conversion.
Racket also has support for floats, similar to what is present in other languages. These floats are called inexact numbers because their accuracy is limited to what can be stored in a certain number of bytes (IEEE standards).

Read more about Racket Numbers.

Since the user inputs a float with a decimal point, we need to convert the number into a fraction using inexact->exact. Once our input is converted, we can extract the denominator and the numerator of the fraction.
((λ (frac [den (denominator frac)] [num (numerator frac)])
   ...)
 (inexact->exact (read)))

After that, We create a format string that will printed with the following format parameters:

The whole part of the fraction.

Calculated by dividing the numerator num by the denominator den.

A simplified version of the remaining fraction.

Modulo the numerator num by the denominator den.
Create a new fraction with the previous step as the numerator and the denominator as den.
Rationalize the new fraction with a tolerance of \$\frac{1}{\text{den}}\$.

((λ (frac [den (denominator frac)] [num (numerator frac)])
   (printf "~a + (~a)"
           (quotient n d)
           (rationalize (/ (modulo n d) d)
                        (/ 1 d))))
 (inexact->exact (read)))

Have a great week further!

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


text:
Create a server in Brainfu*k
Create a brainfu*k program that can act like a simple server. It will be given a JSON representation of a file folder to serve from. It'll look something like this:
{
"something.html":"<!DOCTYPE html><html>...etc",
"styles.css":"#something{background-color:red...etc",
}

and, it will also be given the name of the file to return. No headers or anything, just output the text value of the file. It must output "404" if the file doesn't exist, though. The input will be the JSON, in 1 line, with the file name immediately after it:
{JSON DATA HERE}something.html

and the program will be run whenever a file is requested. So, I guess, it isn't really a server. But, this is brainfu*k, so it isn't perfect.

Apart from the lack of objective winning criteria (what's the goal? Code size? Votes? Just "getting it done" isn't enough)... how is brainfuck going to perform HTTP communication? It only has STDIN and STDOUT through which external libraries can communicate, but you haven't specified any.

“the program will be run whenever a file is requested” – that sounds like it should be run from an internet super-server, like inetd or xinetd. So for communication STDIN and STDOUT is just enough. But no idea how it could perform filesystem operations.

as I said, it isn't really a server (I know brainfu*k can't handle HTTP and the liking), it is simply passed a JSON object representing a filesystem and the name of the "file" to retrieve from that JSON object


text:
Raytracer in odd or high level language
Ray tracers are easy to write.  At each pixel on the screen, you shoot a ray into the scene and see what it hits.  For the most basic ray tracer, the ray acquires the color of the object it hit.
If you're doing shading, then you don't color the pixel immediately, instead you try to trace a ray back to the light source.  The shaded color is then the (color of the surface)*(cosine of the angle (dot product) of ray-to-the-lightsource has with the surface normal).  If the light source cannot be reached, then the object is in shadow.
This challenge is to write the raytracer in any language you can.  The winner is the most succinct code, while still remaining readable (see here for more elegant definitions).
Requirements:

Ray trace spheres
Shading
Shadows
At least 1 bounce interreflection.
You must display your result using pixels or write an image file.  Don't draw into the console.

Bonus:

Include ability to ray trace general polygons
Translucency

Superbonus:

General BRDFs
Subsurface scattering (BSSRDF)

Bad examples:

Don't do this: http://www.teamten.com/lawrence/projects/shortest_ray_tracer/
And don't do this: http://www.kevinbeason.com/smallpt/

The first is not readable.  The 2nd is just a really compact C++ program.
This is a hard project, so you might want to bookmark it and come back later.  I'll leave this open for about a month before awarding the checkmark.
Resources:

http://www.cs.utah.edu/~shirley/irt/

(more will be added later)

Please read the site FAQ for what constitutes a good, well-specified question.

Ok, ok.  I'll flesh it out.

"the shortest x you can" (code-golf) and "while still remaining intelligible to read" are incompatible. If it is code-golf, then the objective measure is character count. "intelligible" is subjective, and prone to taste. In which case this should be code-challenge. Please pick one.

"The 2nd is just a really compact C program". Nope, this is C++ program, and C++ is not C.

Instead of writing "bonus" and "superbonus", please make an objective winning criteria. For example: code size - 20 * (number of bonuses met) - 50 * (number of super-bonuses met) (I am not claiming that is a good criteria). You have this tagged as [tag:code-challenge], so that sort of criteria is expected.

Goraud shading in ray tracer? That doesn't make any sense.

@shiona Well it does, but it's incorrect.  I mean to say Phong.

"Ray tracers are easy to write" - I disagree. "The 2nd is just a really compact C++ program" - so what is wrong with it?

What is this I don't even... what does Rubik's cube have to do with raytracing?

It was just a joke.  1. You're free to disagree. 2. Ray tracers are always written in C++.. how about something different?

This needs a little more work to fulfill the requirements (shading, interreflection), but mostly works. It generates the pixels line-by-line in the callback procedure to the image operator. The readability comes at the expense of being very wasteful with memory, creating and discarding temporary arrays with abandon.
Postscript 90 lines
Uses an external matrix library.
(mat.ps) run  % load matrix library
/div { dup 0 eq { pop 10000 }{ div } ifelse } bind def  % make divide-by-zero safe
/tan { dup sin exch cos div } def

%[vector] scalar {op}  .  [vector']
%create a new vector and fill with the scalar,
%call matrix library's vector-op
/sop {
    exch % [] {} s
    [ exch % [] {} [ s
    3 index length 1 sub{dup}repeat % [] {} [ s*n-1
    ] exch % [] [] {}
    vop
} def

/normalize { dup mag {div} sop } def

<< % parameters
    /Cam    [ 0 0 0 ]   % camera location
    /Lookat [ 0 0 -1 ]  % camera lookat point
    /Up     [ 0 1 0 ]   % up vector
    /fovx   45          % horizontal field of view
    /W      320         % image width
    /H      200         % image height
    /Sc     [ 1 1 -5 ]  % sphere center
    /Sr     2           % sphere radius
>> begin

<< % dependent constants
    /Left Lookat Cam {sub} vop Up cross
    /buf W string
    /fovy H W div fovx mul
    /ang 0
    /pos 3
>> {def} forall  % add these values to existing dictionary

% place the light in the scene according to the /ang parameter
/setLight { /Light [ ang cos pos mul 3 ang sin pos mul ] def } def

0 10 360 { /ang exch def   % for-loop sets /ang, calls image and showpage
setLight                   % place the light
150 200 translate          % position lower left corner of image on page
/y 0 def                   % initial y-value
W H 8                      % put width height depth on stack  for `image` call
[ 1 0 0 1 0 0 ]            % 1-to-1 matrix, so width*height points is the image size
{                          % image procedure yields a string with one image row
    0 1 W 1 sub { /x exch def                   % for-loop iterates over x-values
        Left   x 2 mul W sub W div fovx tan mul  {mul} sop  % construct vector from eye through center of pixel
        Up     y 2 mul H sub H div fovy tan mul  {mul} sop
        Lookat {add} vop {add} vop
        Cam {sub} vop
        normalize /R exch def

        Cam Sc {sub} vop   % use the quadratic formula to check for real intersection
        dup R dot 2 mul /B exch def
        dup dot Sr dup mul sub /C exch def

        B dup mul C 4 mul sub /disc exch def  % discriminant, the part under the radical-sign

        % ray hits sphere? no:0 yes:calculate
        disc 0 lt { 0 }{
            disc sqrt /sdisc exch def  % complete the quadratic formula to yield t value
            B neg sdisc sub .5 mul /t exch def
            t 0 le { B neg sdisc add .5 mul /t exch def } if
            R t {mul} sop
            Cam {add} vop /ri exch def  %intersection point
            ri Sc {sub} vop
            1 Sr div {mul} sop %normalize
            /rn exch def  %surface normal
            Light
            ri
            {sub} vop %normalize
            rn dot  % normal .dot. light-ray
            1 add .3 mul
            %.3 mul
            dup 0 lt {pop 0} if  % clip value into 8-bit range
            dup 1 gt {pop 1} if
            255 mul truncate cvi
        } ifelse   % pixel_color = 0..255

        buf x 3 2 roll put  % put pixel value in string
    } for
    /y y 1 add def  % increase y for next row
    buf  % yield string buffer to image
}
%exec  % image doesn't report internal errors, debug the procedure with `exec`
image
showpage

} bind for

Can generate a numbered series of images using ghostscript. And ImageMagick's convert can compile them into an animated gif.

You're pretty insane.  How did you get so good at PS anyway?

Obsession, and a really bad break-up :). ... More seriously, trying to implement the interpreter itself has greatly improved my ps coding skills.


text:
Make the Matrix Digital Rain using the shortest amount of code
Rules:

Any language you choose (Standard Libraries).
Output displayed in Terminal or Windows Command Processor or any other way you prefer.(width buffer = 80)
ASCII Characters are enough. (may add Unicode)
Shouldn't fill up the entire screen at start-up (Should look like a rain, duh!).
Colors gets bonus points (+5).
Effects : Random characters, different fall sizes, regenerates periodically.

Points: (update)

+32 points to start with.
-1 point for every byte (not chars) in the code after the **1024***th* byte.
Points could reach zero and negative.
Note: Languages using multibyte characters should count bytes not characters.
+5 for every new effect. (not posted by others)
+15 for any of these effects:

Wind(blows characters to the side)
Number Matching(user input, eg:90210):
Number is randomly located within the matrix

Sound
Encrypted msg(user input):
Characters represent a secret encrypted message
Galaga mode:
Fires ^ to destroy characters

Scoreboard:
┌-----┬------------┬------------┬-------------┬---------------┬--------------┐
| pos |    name    |    type    |    bytes    |    effects    |    points  ^ |
|-----|------------|------------|-------------|---------------|--------------|
|1    |nitro2k01   |QBasic      |913          |Colours        |+57           |
|     |            |            |             |Colour Fade    |              |
|     |            |            |             |Sound (+15)    |              |
|-----|------------|------------|-------------|---------------|--------------|
|2    |squeamish   |HTML, Java- |1024         |Colours        |+47           |
|     |ossifrage   |Script, CSS |             |Transition     |              |
|     |            |            |             |Size Variation |              |
|-----|------------|------------|-------------|---------------|--------------|
|3    |manatwork   |Ruby        |374          |Colours        |+47           |
|     |            |            |             |Actual Words   |              |
|     |            |            |             |Character -    |              |
|     |            |            |             |      Disperse |              |
|-----|------------|------------|-------------|---------------|--------------|
|4    |plg         |Bash        |1024         |Colours        |+42           |
|     |            |            |             |Random Pause   |              |
|-----|------------|------------|-------------|---------------|--------------|
|5    |Timtech     |TI-84 calc  |120          |Umbrella       |+42           |
|     |            |            |             |Run Inside     |              |
|-----|------------|------------|-------------|---------------|--------------|
|6    |Samuel Cook |JavaScript  |830          |Colours        |+42           |
|     |            |            |             |Transition     |              |
└-----┴------------┴------------┴-------------┴---------------┴--------------┘

Note : Scoreboard will/could be updated by anyone after posting a valid answer. Do not exceed top ten positions. Add more effects to your code and beat your own score! Clearing initial screen, cleanup, bugs, third party libraries etc. would not count towards the points
Remember to include details about no. of bytes used and the name of language or program.

Neo: What are you trying to tell me? That I can dodge bullets?
Morpheus: No, Neo. I'm trying to tell you that when you're ready, you
  won't have to.

What about libraries?

Include or Import or Require as much libraries as you need(standard libraries)!

Would you add points if the code is under 250 chars? (I have a really short solution but it doesn't have a ton of features)

You won't be needing it; you'd still have +32 points! Chances are, many will exceed the limit and begin to drop points making short codes raise to top on the scoreboard. (also, adding more rules and points would complicate stuff)

Alright, I'll include a golfed version just for fun!

Shell script: 7 characters – cmatrix

I was wondering if anyone could pull off these effects: 1. Wind(blows characters to the side), 2.Number Matching(user input), 3.Sound, 4.Encrypted msg(user input), 5.Galaga mode

@user3058846 Can you clarify what number matching, encrypted message and Galaga mode mean exactly?

@nitro2k01 Edited the question, check it out.

I'm surprised that no one has tried Python yet!

although not in competition, check this : http://www.pouet.net/prod.php?which=63126

Questions without an objective validity criterion are off-topic, as they make it impossible to indisputably decide whether an entry complies with the specification. Looks like rain and new effect are subjective.

HTML, Javascript and CSS: 1024 bytes, 47 points

Features:

Uses Unicode characters (don't think this scores any points though)
Trails fade from bright to dark green while they are being drawn (*)
Trails also fade from dark green to black after the drawing has finished (*)
Random text size in each trail (*)
Trails are randomly repositioned and resized each time they are drawn

(*) I'll claim +5 points for each of these, but let me know if you disagree :-)
Demo:
http://ruletheweb.co.uk/matrix.html
Source code:
Exactly 1024 bytes. It's a bit ugly, I'm afraid.
<head><style>*{margin:0;padding:0;line-height:1;overflow:hidden;}div{width:1em;position:absolute;}</style><script>
w=window;n=w.innerWidth;m=w.innerHeight;d=document;q="px";function z(a,b){return Math.floor(Math.random()*(b-a)+a)}f=" 0123456789";for(i=0;i<45;i++)f+=String.fromCharCode(i+65393);function g(){for(i=0;i<90;i++){r=d.createElement("div");for(j=z(20,50);j;j--){x=d.createElement("pre");y=d.createTextNode(f[z(0,56)]);x.appendChild(y);x.style.opacity=0;r.appendChild(x)}r.id="r"+i;r.t=z(-99,0);with(r.style){left=z(0,n)+q;top=z(-m,0)+q;fontSize=z(10,25)+q}d.body.appendChild(r);setInterval("u("+i+")",z(60,120))}}function u(j){e=d.getElementById("r"+j);c=e.childNodes;t=e.t+1;if((v=t-c.length-50)>0){if((e.style.opacity=1-v/32)==0){for(f in c)if(c[f].style)c[f].style.opacity=0;with(e.style){left=z(0,n)+q;top=z(-m/2,m/2)+q;opacity=1}t=-50}}e.t=t;if(t<0||t>c.length+12)return;for(f=t;f&&f>t-12;f--){s=1-(t-f)/16;if(f<c.length&&c[f].style){c[f].style.opacity=s;}}}
</script><body text=#0f0 bgcolor=#000 onload=g()>

It looks good as a screen shot but it eats the crap out of my resources. +1 from me

Really cool! I might steal your unicode characters :) +1

UglifyJS can remove 17 characters from JavaScript source code. Not that it really matters, as this is not code golf (rather, max 1024 characters challenge).

This is by far the best version of this I have found on the first two pages of Google results. I just really wish you had had some room to actually remove some of the nodes you are adding :) really kills my computer to leave that open

Do you by chance have the original pre-uglified code? I would love to understand how this is done.

@Chin Is this better?

That's great, thanks! I don't quite understand the part around the opacity being result of some function of the age divided by 16 and 32 - are those numbers arbitrary or is there a special meaning to them? Also another interesting thing I noticed is this consumes much less system resource on Firefox instead of Chrome, not sure why, but Chrome seems to max out my GPU.

@Chin The opacity variation was just added to make the characters fade after a while. If you fiddle around with the numbers, you should be able to see what's happening. And yes, it is quite demanding on the processor.

Bash
1024 bytes (including comments)
COL=80
ROW=$(tput lines)

cleanup() {
  wait # wait for background jobs (the drops)
  # clear; move cursor to (1,1); show cursor
  # reset color
  printf '\033[2J\033[1;1H\033[?25h\033[0;0m'
}

drop() { # $1=column ; $2=row to end on ; $3 = drop size (ranges from 5 to 15)
  for ((r=1; r<$2+$3+1; r++)); do
    # if before drop's end point : print lowest char in white
    [ $r -lt $2 ] && printf "\033[$r;$1H\033[0;0m\u$[RANDOM % 59 + 21]"

    # if before or on drop's end point : replace older white char with a green one
    [ $r -le $2 ] && printf "\033[$[r-1];$1H\033[0;32m\u$[RANDOM % 59 + 21]"

    # if drop's longer than it's size : erase last char
    [ $r -gt $3 ] && printf "\033[$[r-$3];$1H "

    # wait before moving drop down
    sleep .1
  done
}

# cleanup on exit
trap cleanup EXIT
# clear screen; hide cursor
printf '\033[2J\033[?25l'

# loop with delay
while sleep .1; do
  # start a drop in background : column; ending row; size
  drop $[RANDOM % COL] $[RANDOM % ROW + ROW/3] $[RANDOM % 10 + 5] &
done

New effects:

everything (first entry) ;)
drops will stop randomly on the screen
cool color effects: the last char is white while the others are green
random chars and escape sequences stay on the console... Ok, that's a bug but it's because the term can't keep up with the cursor movement

Golfed @ 188 186 176 :
d(){ for((r=1;r<$2+41;r++));do $4"$3$r;$1H\u$[RANDOM%59+21]";(($r>$2))&&$4"$3$[r-$2];$1H ";$s;done;}
s=sleep\ .1;while $s;do d $[RANDOM%80] $[RANDOM%10+5] '\033[' printf\ &done

This works in a 80x40 grid. You can change that in RANDOM%80 on the last line, and r<$2+41 on the 2nd one. I don't clear the drops after they get out of the grid so either resize your term to 80x40 or change 41 to $LINES+1.
There are a couple things it doesn't have compared to the full version :

term preparation or cleanup
fancy coloring (takes 52 bytes, so not worth it)
stopping randomly (here drops always go down to the bottom)
I could bring it down to 174 by not specifying a minimum length for "drops" : $[RANDOM%10+5] would become $[RANDOM%15]

Even with those limitations I think it's pretty cool!
Edit:
I tried using unicode chars like squeamish ossifrage, but because they're double width chars they fill the grid pretty rapidly and it ends up looking strange.
I also reduced the golfed version by using unicode code points instead of ASCII, so I don't have to go octal before getting a character, saving a step. I did the same thing in the main version, but added comments to keep it at 1024 bytes.
And then changed int comparison from [ $r -gt $2 ] to (($r>$2)), that white space was killing me but I couldn't find another method that compared ints and not strings. This got the golfed version down to 176 btyes!

the golfed one is a bit of a fork-bomb, too ;)

@RobStarling they both are actually!

Really loving this! I've tinkered with it a little and it seems you could make it green by changing \033[ to \033[0;32m\033[ (at least in my terminal).
How bad an idea is it to try and set this up as a terminal screensaver? :P

Hmm. I'm getting 1059 bytes for first one and 190 bytes for the second.

@DomHastings Yeah, the full version does coloring, I just didn't want to add extra bytes to the golf one, especially because having nice coloring (ie. not ALL green) requires 52 bytes. If you think this is cool check this out. I found that after I wrote mine, and he has stuff like Mandelbrot fractal, fire animation nyan cat, he's great!

@user3058846 Your text editor uses \r\n as line endings, I used the plain \n. My reasoning behind this : first script is 36 lines, you added \r to each line ending so you added 35 bytes (if there's no trailing newline). Lo and behold 1024 + 35 = 1059. Same thing for script 2: 188 + 2 = 190

Fixed the EOL Characters (Windows defaults to \r\n, but I think Unix systems use \n)

Tried it, that's awesome! you're good.

You guys are basically wizards! Thanks for sharing!

JavaScript, 830 bytes
It has all of the classic features like:

black background
green text
white text when falling
random characters
empty holes
infinite looping

window.onload=function(){
    var tbl=document.createElement('table'),
 body=document.body;
 body.style.backgroundColor='#000';
 body.style.color='#060';
 body.style.fontFamily='Lucida Console';

    for(var i = 0; i <= 30; i++){
        var tr = tbl.insertRow();
        for(var j = 0; j <= 50; j++){
            var td = tr.insertCell();
   td.style.width="2%";
        }
    }
    body.appendChild(tbl);
 setInterval(function(){
  rain(Math.floor((Math.random()*50)),0)
 },20);
}
function rain(n,i) {
   setTimeout(function (){
   var e=document.getElementsByTagName('tr')[i].childNodes[n];
   e.style.color='#fff';
      e.innerHTML = '&#'+Math.floor((Math.random()*127)+1)+';';
   setTimeout(function(){e.style.color=''},200)

      if (i++ < 30) rain(n,i);
   },20);
};

I like it because it is incredibly light weight, fluid in motion, and simple. enjoy!

QBasic 1, 587 bytes, 32+5=37 points
DECLARE SUB d (p!, s!, x!, y!)
DIM t(80)
FOR i = 1 TO 80
    t(i) = INT(-50 * RND)
NEXT
s = TIMER

CLS
WHILE 1
    FOR i = 1 TO 80
        IF t(i) > 28 THEN t(i) = 0
        t(i) = t(i) + 1
        y = t(i)
        d 0, 0, i, y - 6
        d 2, 0, i, y - 5
        d 2, 0, i, y - 4
        d 10, 0, i, y - 3
        d 10, 0, i, y - 2
        d 11, 0, i, y - 1
        d 0, 2, i, y
    NEXT

    l = TIMER
    WHILE l = TIMER
    WEND
WEND

SUB d (p, s, x, y)
COLOR p, s
IF y > 0 AND y < 24 THEN LOCATE y, x: PRINT CHR$(33 + (x * y) MOD 200);
END SUB

Sample screenshot:

32 base points + 5 points for color. But since I'm floating happily well below 1024 byte even without whitespace trimming or optimization, let's add a few more things to steal some points:
QBasic 2, 913 bytes, 32+5+15+5=57 points
DECLARE SUB d (p!, s!, x!, y!)
DIM t(80)
FOR i = 1 TO 80
    t(i) = INT(-50 * RND)
NEXT
s = TIMER
f = 0
w$ = "bullet"
o = 1
CLS
WHILE 1
    FOR i = 1 TO 80
        IF t(i) > 28 THEN t(i) = 0: IF f THEN SOUND 100 * i, 1
        t(i) = t(i) + 1
        y = t(i)
        d 0, 0, i, y - 6
        d 2 + x, 0, i, y - 5
        d 2 + x, 0, i, y - 4
        d 10 + x, 0, i, y - 3
        d 10 + x, 0, i, y - 2
        d 11 + x, 0, i, y - 1
        d 0, 2 + x, i, y
    NEXT
    k$ = INKEY$
    IF k$ <> "" THEN
        IF MID$(w$, o, 1) = k$ THEN
            o = o + 1
            IF o = LEN(w$) + 1 THEN z = 1: f = 100
        ELSE
            o = 1
        END IF

    END IF
    x = x + z
    l = TIMER
    WHILE l = TIMER
    WEND

WEND

SUB d (p, s, x, y)
COLOR p MOD 16, s MOD 16
IF y > 0 AND y < 24 THEN LOCATE y, x: PRINT CHR$(33 + (x * y) MOD 200);
END SUB

Sample screenshot (color effect activated):

Same features as the first one. Additionally it has:

Color (+5)
A password to activate extra features. (I'm claiming +5 for this as a new feature.)
The password activates a palette fade and sound effects. (+15 for sound.)

Video showing it in action, including the color effect and sound effect activated by the password:
http://www.youtube.com/watch?v=MQc-FDl_AZ8

GTB, 42 points
Executed from a TI-84 calculator, about 100 bytes:
"  O O    O O   O"→Str1:"O  O   O O  O O "→Str2:0→X[@getkey=25$~""~""~""~""~""~""~""p;&@round(r;$~""#@round(r;$~Str1#~Str2&:&]

Effects
Since the calculator is black + white to begin with, can't do much there...

Umbrella - Pressing the up key clears off the rain and keeps you dry until you press Enter
Run Inside - Pressing ON breaks the program and gives you a nice roof to keep you dry (you can go back out into the rain by pressing Enter twice

works perfectly on my TI-92! Awesome.

@user3058846 I'm glad you like it :) I wasn't aware that GTB could execute on TI-92's though.

TI-92 Plus actually.

@user3058846 So you downloaded the compiler eh? Nice work :)

Ruby: 374 characters
$><<"^[[2J"
w=->c,d,m{$><<"^[[0;3%d;%dm^[[%d;%dH%s"%[c,d[4],d[3]+d[1]-m,d[2],d[0][d[1]-m]]}
t=%w{Stack Exchange Programming Puzzle Code Golf}
r=[]
loop{r.map{|o|w[2,o,1]if o[1]>0
w[7,o,0]
o[1]+=1
o[0][0]==" "?r.delete(o):(o[0]=" "*o[1])*o[1]=0if o[1]>o[0].size}
sleep 0.1
r<<[(k=rand(10)%2)==0 ?t.sample: [*?a..?z].sample(rand(10)+5)*"",0,rand(80),rand(20),k+1]while r.size<25}

(Note: ^[ are single characters.)
Description:

25 simultaneous runs (kept low so the predefined texts remain readable)
each run has 50% / 50% chance to be either

a predefined word – displayed in bright colors
a random string of 5..15 lowercase letters – displayed in dark colors

while displaying the run the bottom color is white, the others green
after the run is fully displayed, it is removed character by character

Sample run:

How many bytes (not characters)?

Only single byte characters used, so 374 bytes.

Really liked your version! Keep up the good work.


text:
Sort the distinct elements of a list in descending order by frequency
Write a function which takes a list or array, and returns a list of the distinct elements, sorted in descending order by frequency.
Example:
Given:
["John","Doe","Dick","Harry","Harry","Doe","Doe","Harry","Doe","John"]

Expected return value:
["Doe","Harry","John","Dick"]

Code-golf or code-challenge?

Code-golf. That was mistake. Just correct it

APL (14)
{∪⍵[⍒+⌿∘.≡⍨⍵]}

This is a function that takes a list, e.g.:
      names
 John  Doe  Dick  Harry  Harry  Doe  Doe  Harry  Doe  John
      {∪⍵[⍒+⌿∘.≡⍨⍵]} names
 Doe  Harry  John  Dick

Explanation:

∘.≡⍨⍵: compare each element in the array to each other element in the array, giving a matrix
+⌿: sum the columns of the matrix, giving how many times each element occurs
⍒: give indices of downward sort
⍵[...]: reorder ⍵ by the given indices
∪: get the unique elements

And yet somehow they call going from this concise witty language to Java "progress"? (-:

Python 3 - 47 43; Python 2 - 40 39
For Python 3:
f=lambda n:sorted(set(n),key=n.count)[::-1]

For Python 2:
f=lambda n:sorted(set(n),cmp,n.count,1)

Demo:
>>> names = ["John","Doe","Dick","Harry","Harry","Doe","Doe","Harry","Doe","John"]
>>> f(names)
['Doe', 'Harry', 'John', 'Dick']

I was trying to post the same, but here is a modification. f=lambda n:sorted(set(n),cmp,n.count,1) 39 characters

Hmm, I didn't realize you could pass both a non-None cmp function and a key function. Cool.

A bit shorter: f=lambda n:sorted(set(n),key=n.count)[::-1]

Thanks @grc, the alien smiley does save some characters in the Python 3 case.

Mathematica, 31
Sort[GatherBy@n][[-1;;1;;-1,1]]

{"Doe", "Harry", "John", "Dick"}

(With n = {"John", "Doe", "Dick", "Harry", "Harry", "Doe", "Doe", "Harry", "Doe", "John"})

Darn, you got me there :D

@YvesKlett Thanks. I'm thinking of getting rid of Reverse, but Sort[GatherBy@n][[-1;;1, 1]] does not work:). Any ideas?

Ahh, got it http://mathematica.stackexchange.com/a/22320/745

Mathematica (26 37)
With n = {"John", "Doe", "Dick", "Harry", "Harry", "Doe", "Doe", "Harry",
  "Doe", "John"}:
Last/@Gather@n~SortBy~Length//Reverse

{"Doe", "Harry", "John", "Dick"}

Mathematica V10+ (26):
Keys@Sort[Counts[n],#>#2&]

@garej older version in use. Post as another answer?

I've added to yours if you do not mind...

@garej. Thanks, excellent solution!

Perl 6 (36 bytes, 35 characters)
» can be replaced with >>, if you cannot handle UTF-8. I'm almost sure this could be shorter, but the Bag class is relatively strange in its behavior (sadly), and isn't really complete, as it's relatively new (but it can count arguments). {} declares an anonymous function.
{(sort -*.value,pairs bag @_)».key}

Sample output (from Perl 6 REPL):
> my @names = ("John","Doe","Dick","Harry","Harry","Doe","Doe","Harry","Doe","John")
John Doe Dick Harry Harry Doe Doe Harry Doe John
> {(sort -*.value,pairs bag @_)».key}(@names)
Doe Harry John Dick

Ruby: 34 37 characters
f=->a{a.sort_by{|z|-a.count(z)}&a}

(edited: previous 30-char solution was the body of the function)

You can trim a few characters with f=->a{a.sort_by{|z|-a.count(z)}&a} . The & does a uniq.

GolfScript, 14 chars (19 as named function, also 14 as full program)
:a.|{[.]a\-,}$

This code takes an array on the stack and sorts its unique elements in descending order by number of occurrences.  For example, if the input array is:
["John" "Doe" "Dick" "Harry" "Harry" "Doe" "Doe" "Harry" "Doe" "John"]

then the output array will be
["Doe" "Harry" "John" "Dick"]

Note: The code above is a bare sequence of statements.  To turn it into a named function, wrap it in braces and assign it to a name, as in:
{:a.|{[.]a\-,}$}:f;

Alternatively, to turn the code into a full program that reads a list from standard input (using the list notation shown above) and prints it to standard output, prepend ~ and append ` to the code.  The [. can be omitted in this case (since we know there will be nothing else on the stack), so that the resulting 14-character program will be:
~:a.|{]a\-,}$`

How does it work?

:a saves a copy of the original array in the variable a for later use.
.| computes the set union of the array with itself, eliminating duplicates as a side effect.
{ }$ sorts the de-duplicated array using the custom sort keys computed by the code inside the braces.  This code takes each array element, uses array subtraction to remove it from the original input array saved in a, and counts the number of remaining elements.  Thus, the elements get sorted in decreasing order of frequency.

Ps. See here for the original 30-character version.

I think that [a\])^ should be equivalent to [.;]a\-. Sorting by number of non-matching elements is a nice idea.

Alas, no: ^ collapses duplicates, - doesn't. (And ITYM (, not ).) [a\](\- would work, but wouldn't save any characters.

R: 23 characters
n <- c("John","Doe","Dick","Harry","Harry","Doe","Doe","Harry","Doe","John")

names(sort(table(n),T))
## [1] "Doe"   "Harry" "John"  "Dick"

But it uses the not so nice shortcut of T to TRUE...

K (ngn/k), 5 bytes
>#'=:

Try it online!

=: group the input, building a dictionary mapping unique values to the indices in which they appear
#' take the count of each set of indices
> sort the keys of the dictionary by their values, descending

if this could fit here : In sql-server
create table #t1 (name varchar(10))
insert into #t1 values ('John'),('Doe'),('Dick'),('Harry'),('Harry'),('Doe'),('Doe'),('Harry'),('Doe'),('John')

select name from #t1 group by name order by count(*) desc

OR
with cte as
(

select name,count(name) as x from #t1 group by name
)

select name from cte order by x desc

see it in action

Why the CTE? select name from #t1 group by name order by count(*) desc

PHP, 63 62 61 chars
function R($a){foreach($a as$v)$b[$v]++;arsort($b);return$b;}

Demo:
$c = array("John","Doe","Dick","Harry","Harry","Doe","Doe","Harry","Doe","John");
$d = print_r(R($c));

Array ( [Doe] => 4 [Harry] => 3 [John] => 2 [Dick] => 1 )

have a look at array_count_values()… That's all you have to use (including arsort())

array_count_values() does not delete duplicated values, nor orders them, as I can see.

It deletes the duplicates … It just doesn't order them… => arsort

@bwoebi You are right. Unfortunately writing it that way is 1 character longer than this answer.

Why is the way with array_count_values longer? <?$u=array_count_values($_GET);arsort($u);print_r($u); are 54 Bytes in my opinion

Ruby: 59 characters
f=->n{n.group_by{|i|i}.sort_by{|i|-i[1].size}.map{|i|i[0]}}

Sample run:
irb(main):001:0> f=->n{n.group_by{|i|i}.sort_by{|i|-i[1].size}.map{|i|i[0]}}
=> #<Proc:0x93b2e10@(irb):2 (lambda)>

irb(main):004:0> f[["John","Doe","Dick","Harry","Harry","Doe","Doe","Harry","Doe","John"]]
=> ["Doe", "Harry", "John", "Dick"]

Mathematica, 39 characters
f = Reverse[First /@ SortBy[Tally@#, Last]] &

names = {"John", "Doe", "Dick", "Harry", "Harry",
         "Doe", "Doe", "Harry", "Doe", "John"};

f@names

{Doe, Harry, John, Dick}

JavaScript (ECMAScript5): 118 113 characters
function f(n){m={}
for(i in n){m[n[i]]=m[n[i]]+1||1}
return Object.keys(m).sort(function(a,b){return m[b]-m[a]})}

http://jsfiddle.net/mblase75/crg5B/

With Harmony's fat arrow functions: f=n=>{m={};n.forEach(e=>m[e]=m[e]+1||1);return Object.keys(m).sort((a,b)=>m[b]-m[a])}. (Currently only in Firefox.)

You can use m[n[i]]=-~m[n[i]] to increment, and you don't need {}s around the loop body.

C#: 111 characters
List<string>M(List<string>l){return l.GroupBy(q=>q).OrderByDescending(g=>g.Count()).Select(g=>g.Key).ToList();}

(inside a class)
var names = new List<string> {"John", "Doe", "Dick", "Harry", "Harry", "Doe", "Doe", "Harry", "Doe", "John"};
foreach(var s in M(names))
{
    Console.WriteLine(s);
}

Doe
Harry
John
Dick

A simple solution using LINQ.

You could also remove the .ToList(), since the sequence get enumerated via the foreach

That's true, but then I'd have to change the return type into IEnumerable.

Haskell - 53 Characters
import Data.List
import Data.Ord

f :: (Eq a, Ord a) => [a] -> [a]
f=map head.(sortBy$flip$comparing length).group.sort

Explanation: the first two lines are necessary imports, the next line of code is the type signature (generally not necessary), the actual function is the last line.
The function sorts the list by its natural ordering, groups equal elements into lists, sorts the list of lists by descending size, and takes the first element in each list.
total length including imports: 120
w/o imports but with type signature: 86
function itself: 53

Clojure: 43 characters
Function:
#(keys(sort-by(comp - val)(frequencies %)))

Demo (in repl):
user=> (def names ["John","Doe","Dick","Harry","Harry","Doe","Doe","Harry","Doe","John"])
#'user/names
user=> (#(keys(sort-by(comp - val)(frequencies %))) names)
("Doe" "Harry" "John" "Dick")

J, 8 bytes
~.\:#/.~

Usage
The names are stored as an array of boxed strings.
   'John';'Doe';'Dick';'Harry';'Harry';'Doe';'Doe';'Harry';'Doe';'John'
┌────┬───┬────┬─────┬─────┬───┬───┬─────┬───┬────┐
│John│Doe│Dick│Harry│Harry│Doe│Doe│Harry│Doe│John│
└────┴───┴────┴─────┴─────┴───┴───┴─────┴───┴────┘
   f =: ~.\:#/.~
   f 'John';'Doe';'Dick';'Harry';'Harry';'Doe';'Doe';'Harry';'Doe';'John'
┌───┬─────┬────┬────┐
│Doe│Harry│John│Dick│
└───┴─────┴────┴────┘

Explanation
~.\:#/.~   Input: A
    #/.~   Finds the size of each set of identical items (Frequencies)
~.         List the distinct values in A
           Note: the distinct values and frequencies will be in the same order
  \:       Sort the distinct values in decreasing order according to the frequencies
           Return the sorted list implicitly

CJam, 15 bytes
q~$e`{0=W*}$1f=

This may use CJam features from after this challenge was posted. I'm too lazy to check.

05AB1E, 5 bytes
ÙΣ¢}R

Try it online.
Explanation:
Ù    # Uniquify the (implicit) input-list
 Σ   # Sort this uniquified list by:
  ¢  #  Get its count in the (implicit) input-list
 }R  # After the ascending sort: reverse the list, so it'll become descending
     # (after which the result is output implicitly)

Stax, 7 bytes
èó±☻₧╛╗

Run and debug it

Jelly, 6 bytes
Qċ@ÞṚ⁺

Try it online!
There are quite a few ways to formulate this, but I find this to be the most amusing of several 6-byte alternatives. ċ@Þ@QṚ comes rather close.
Q         Unique items of the input.
   Þ      Sort them by
 ċ@       how many times they appear in the input
    Ṛ     reversed.
     ⁺    Duplicate the last link: reverse the sorted result.

Husk, 5 bytes
u↔Ö#¹

Try it online!

Factor, 33 bytes
[ sorted-histogram keys reverse ]

Try it online!
Explanation
                 ! { "John" "Doe" "Dick" "Harry" "Harry" "Doe" "Doe" "Harry" "Doe" "John" }
sorted-histogram ! { { "Dick" 1 } { "John" 2 } { "Harry" 3 } { "Doe" 4 } }
keys             ! { "Dick" "John" "Harry" "Doe" }
reverse          ! { "Doe" "Harry" "John" "Dick" }

Perl
to meet given i/o spec I need 120 chars
s!"([^"]+)"[],]!$a{$1}++!e while(<>);print 'MostOccuring = [',join(',',map{qq("$_")}sort{$a{$a}<=>$a{$b}}keys %a),"]\n"

pure shortest code by taking one item per line and printing one item per line I only need 55 chars
$a{$_}++ while(<>);print sort{$a{$a}<=>$a{$b}}keys %a)

Scala (71)
(x.groupBy(a=>a)map(t=>(t._1,t._2.length))toList)sortBy(-_._2)map(_._1)

Ungolfed:
def f(x:Array[String]) =
  (x.groupBy(a => a) map (t => (t._1, t._2.length)) toList)
    sortBy(-_._2) map(_._1)

Perl 5, 51 bytes
sub f{my%k;$k{$_}++for@_;sort{$k{$b}-$k{$a}}keys%k}

Try it online!