text:
Shuffle a deck without local variables
The object of this puzzle is to take a deck of 52 cards and shuffle it so that each card is in a random position.
Given:

An array, deck, of 52 distinct integers representing the cards. When you start, deck contains exactly one of each card in some unknown order.
A function, int rand(min, max), that returns a random integer between ints min and max, inclusive. You can assume that this function is truly random.
A function, void swap(x, y) that swaps two cards in the deck. If you call swap(x, y), the cards at positions x and y will switch places.

When:

The program calls shuffle() (or shuffle(deck) or deck.shuffle() or however your implementation likes to run),

Then:

deck should contain exactly one of each card in perfectly random order.

The Catch:
You can't declare any variables. Call swap and rand as much as you like, but you can't declare any variables of your own. This includes for loop counters--even implicit ones like in a foreach.
Clarifications:

You can change minor details to suit your chosen language. For example, you can write swap to switch two integers by reference. Changes should be to make this work with your language, not to make the puzzle easier.
deck can be a global variable, or you can take it in as a parameter.
You can do anything you want to the contents of deck, but you can't change its length.
Your cards can be numbered 0-51, 1-52, or anything you like.
You can write this in any language, but no cheating with your language's built-in shuffle function.
Yes, you could write the same line 52 times. No one will be impressed.
Execution time doesn't matter, but true randomness does.
This isn't really code golf, but feel free to minimize/obfuscate your code.

Edit: Boilerplate code and visualizer
If you used .NET or JavaScript, here's some test code you may find useful:
JavaScript:

Quick-and-dirty JavaScript visualizer, with CoffeeScript source: https://gist.github.com/JustinMorgan/3989752bdfd579291cca
Runnable version (just paste in your shuffle() function): http://jsfiddle.net/4zxjmy42/

C#:

ASP.NET visualizer with C# codebehind: https://gist.github.com/JustinMorgan/4b630446a43f28eb5559
Stub with just the swap and rand utility methods: https://gist.github.com/JustinMorgan/3bb4e6b058d70cc07d41

This code sorts and shuffles the deck several thousand times and performs some basic sanity testing: For each shuffle, it verifies that there are exactly 52 cards in the deck with no repeats. Then the visualizer plots the frequency of each card ending up at each place in the deck, displaying a grayscale heat map.
The visualizer's output should look like snow with no apparent pattern. Obviously it can't prove true randomness, but it's a quick and easy way to spot-check. I recommend using it or something like it, because certain mistakes in the shuffling algorithm lead to very recognizable patterns in the output. Here's an example of the output from two implementations, one with a common flaw:

The flawed version does partially shuffle the deck, so might look fine if you examined the array by hand. The visualizer makes it easier to notice a pattern.

Many languages model arrays as effectively infinite, thus allowing $deck[52] and onwards to be used in place of local variables. Perhaps this should be prohibited too.

Are functions considered variable? are function parameters considered variables?

@Timwi - Good call, I've edited to clarify that.

@zzzzBov - What I had in mind was that function parameters would be considered variables, but I didn't specify that before @mellamokb's answer. I know it can be done without any parameters other than deck itself.

-1 for upping a wrong answer.

@eBusiness - That's a problem with me, not the question itself. And I was upvoting because the answerer found a loophole.

@Justin E. Morgan - It becomes a problem with the question, if you fail to arbiter it the requirements goes down the drain.

@eBusiness - I think that's up to the community. I'm not able to act as an arbiter because I don't know every language, and I don't have a compiler for (for example) Haskell. Besides, I only have one vote anyway, so I wouldn't have much arbitration power.

You can vote on as many answers as you like, but only accept one. If you don't understand a solution, demand it explained at least so well that you understand how it works.

@Justin E. Morgan: Installing the Haskell Platform for Windows takes 91.3MB bandwidth and about 12 mouse clicks.

@Joey - Cool, let's do this! I won't be able to write much of a tester for your code right away, but I've been wanting to get into Haskell for a while.

What's the use case of the swap function, when you can alter the array (deck) in place?

@user unknown - You can swap values any way you like; I only offered the swap function as given because I considered it a less interesting part of the problem. I also wanted to remove any confusion about whether its parameters counted as declared variables. As you can see, some answerers chose to implement their own version, especially in JavaScript answers.

@user unknown - Actually I'm not quite sure I understand your question. My idea was that you would swap two cards in the deck by calling swap(deck[a], deck[b]) or something like that. The JavaScript implementations tend to call swap(deck, a, b) to swap the cards at positions a and b.

Well, my question is, if you have a somewhat global deck, and only allow swapping in the deck, the parameters for the swap function should just take two indicees, and swap the values at that index. This would allow a language like Java to participate, where you can't pass int-references and have them swapped from the function, since you only pass a copy of a reference. Am I too pedantic?

@user unknown - I think I understand. The answer is basically that you can assume whatever implementation of swap you like, as long as it fulfills its basic purpose. Part of my reason for making swap a given was so that people could treat it as 'magic' and concentrate on the main problem without having to worry about it working in their language of choice. You can either do that or write your own swap, it's up to you.

JavaScript
I believe this is the intended form of solution, I use the card in position 0 to keep track of progress, only shuffling the cards that have already been used as counter, this achieves the standard 52! permutations with a perfect equal distribution. The procedure is complicated by XOR swap not allowing that an element is swapped by itself.
Edit: I built in a sorting that sorts each element into place just before it is used, thus allowing this to work with an unsorted array. I also dropped recursive calling in favour of a while loop.
deck=[]
for(a=0;a<52;a++){
    deck[a]=a
}
function swap(a,b){
    deck[a]=deck[b]^deck[a]
    deck[b]=deck[b]^deck[a]
    deck[a]=deck[b]^deck[a]
}
function rand(a,b){
    return Math.floor(Math.random()*(1+b-a))+a
}
function shuffle(){
    while(deck[0]!=0){ //Sort 0 into element 0
        swap(0,deck[0])
    }
    while(deck[0]<51){ //Run 51 times
        while(deck[deck[0]+1]!=deck[0]+1){ //Sort element deck[0]+1 into position deck[0]+1
            swap(deck[deck[0]+1],deck[0]+1)
        }
        swap(0,deck[0]+1) //Swap element deck[0]+1 into position 0, thus increasing the value of deck[0] by 1
        if(rand(0,deck[0]-1)){ //Swap the element at position deck[0] to a random position in the range 1 to deck[0]
            swap(deck[0],rand(1,deck[0]-1))
        }
    }
    if(rand(0,51)){ //Swap the element at position 0 to a random position
        swap(0,rand(1,51))
    }
}
for(c=0;c<100;c++){
    shuffle()
    document.write(deck+"<br>")
}

That's exactly what I had in mind. Soon as I test this I'll upvote and probably accept.

Appears to work fine, although on closer inspection it's not exactly the same as mine. Accepted, and I'll post my own answer soon.

This is also known as Knuth shuffle algorithm (http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle).

Haskell
Here is a point-free implementation.  No variables, formal parameters, or explicit recursion.  I used lambdabot's @pl ("pointless") refactoring feature quite a bit.
import Data.List
import Control.Applicative
import Control.Monad
import System.Random

shuffle :: [a] -> IO [a]
shuffle = liftM2 (<$>) ((fst .) . foldl' (uncurry ((. flip splitAt) . (.) .
          (`ap` snd) . (. fst) . flip flip tail . (ap .) . flip flip head .
          ((.) .) . (. (++)) . flip . (((.) . (,)) .) . flip (:))) . (,) [])
          (sequence . map (randomRIO . (,) 0 . subtract 1) . reverse .
          enumFromTo 1 . length)

main = print =<< shuffle [1..52]

Here's my test procedure to make sure the numbers were uniformly distributed:
main = print . foldl' (zipWith (+)) (replicate 52 0)
       =<< replicateM 1000 (shuffle [1..52])

Here is the original algorithm:
shuffle :: [a] -> IO [a]
shuffle xs = shuffleWith xs <$>
             sequence [randomRIO (0, i - 1) | i <- reverse [1..length xs]]

shuffleWith :: [a] -> [Int] -> [a]
shuffleWith xs ns = fst $ foldl' f ([], xs) ns where
    f (a,b) n = (x:a, xs++ys) where
        (xs, x:ys) = splitAt n b

+1 for Haskell. Now I have to learn Haskell so I can read this. :P

How is the progress stored?

@Justin E. Morgan: My point-free answer doesn't exactly jump out as "readable" to me.  The second and third code blocks should be readable, though.

@eBusiness: In shuffleWith, it starts with the tuple ([], xs), where xs is the deck, and pulls out items numbered by ns (which contains the random numbers needed by the algorithm).  It builds a new list while destroying the old list.  Thus, "progress" is tracked by the state of the accumulator used in the left fold.

I doubt anyone but Haskell programmers will say that their code is pointless and be proud of it.

This ((.) .) . (. (++)) and this (((.) . (,)) .) are my favorite. Wow lambdabot. Just, wow.

@eBusiness "point free" is not at all the same as "pointless".

@FredOverflow That is no doubt the offset for an interesting discussion, but it was Joey who called @pl pointless, I just took the bait and made fun of Haskell. A language that by the way is much like Brainfuck in that people are proud if they manage to write a meaningful program in it.

Good Lord!  This is starting to look like Unlambda.

J
Ignoring that deck is a variable, there's the obvious...
52 ? 52

Of course, if you really want a function, there's this, which will work even if you forget to remove the jokers (or try to shuffle something other than cards).
{~ (# ? #)

So that...
shuffle =: {~ (# ? #)
deck =: i. 52
shuffle deck

This is probably outside the intent of the question, which would be to implement the shuffle yourself from rand (?). I might do that later when I'm not supposed to be working.
Explanation
Explanation of 52 ? 52:

x ? y is x random unique items from y.

Explanation of {~ (# ? #) is harder because of forks and hooks. Basically, it is the same as shuffle =: 3 : '((# y) ? (# y)) { y', which has one implicit argument (y).

# y gives the length of y
This gives 52 ? 52 like before, which is a random permutation of 0..51
x { y is the item of y in index x, or (in this case) items in the indexes in x.
This lets you shuffle whatever is passed in, not just integers.

See J Vocabulary for details of operators, though the syntax and semantics are quite a bit tricky because of rank and tacit programming.

+1: Working on code-golf when supposed to be working.. lol I am too :P

Can you explain what this does for the J-impaired? I recently heard it described as an explosion in an emoticon factory (http://codegolf.stackexchange.com/questions/1294/anagram-code-golf/1296#1296), which sounds about right.

@Justin: Explanation added.

This works in APL too. The syntax is the same, so I won't bother adding a new answer ({52?⍵} is an anonymous function that takes 52 random items from its argument, which here would be a list of 52 integers)

Python
import random
def rand(x, y):
 return random.randrange(x, y+1)

def swap(deck, x, y):
 deck[x] ^= deck[y]
 deck[y] ^= deck[x]
 deck[x] ^= deck[y]

def shuffle(deck):
 if len(deck)>1:
  deck[1:]=shuffle(deck[1:])
  if rand(0,len(deck)-1)>0:swap(deck, 0, rand(1, len(deck)-1))
 return deck

print shuffle(range(52))

What does the [1:] mean? Does that recurse on a sub-array of deck?

Yes, [1:] means the subarray from index 1 to the end of the array.  So it recursively shuffles everything but the first element, assigns (copies) it back to the same place in the original array, then randomly places the first element somewhere.

Very clever. I think this is one of the prettiest solutions on here, and it uses the Fisher-Yates algorithm correctly. +1. This has been a nice way for me to see the beauty of languages I'm not familiar with.

You may like the a, b = b, a trick.

Using factoradic representation
In the factoradic representation of a permutation an element i takes values from 0 to N-i. So a random permutation is just rand(0,i) for every N-i.
In J:
? |.>:i.52
2 39 20 26 ... 2 0 1 0 0 0

where ? x is rand(0,x-1) and |.>:i.52 is 52 51 ... 1
Then, if a is the value of ith factoradic, we do the swap: swap(deck[i], deck[i+a]).
The list of pairs to swap are:
(,. i.52) ,. (,. ((?|.>:i.52)+i.52))
0 33
1 20
2  3
...
49 50
50 50
51 51

The swap we'll be using works like this:
deck
24 51 14 18 ...
deck =: 0 1 swap deck
51 24 14 18 ...

It's not really "by reference" but there are no real functions in J.
We'll use deck's length (#deck) to avoid using a constant.
Complete program in J:
deck =: 52 ? 52                           NB. Initial random deck
swap =: 4 : 'deck =: (x { y) (|.x) } y'   NB. Given swap "function"
f =: 3 : 0                                NB. function that calls the swap for a pair
({.y) swap deck
}.y
)
f^:(#deck) (,.,.[:,.]+[:?[:|.>:) i.#deck

C#
Here's my own answer based on the Fisher-Yates algorithm. Should give you a perfect shuffle if your random number generator is good enough.
English version:

Repeatedly swap the card at deck[0] with the one at deck[v], where v is the face value of the card at deck[0]. Repeat until v == 0. This will partially sort the deck, but that doesn't matter. You now know Card 0 is at the front of the deck, which means you can steal that space in the array and use it as a loop counter. This is the key "cheat" for the problem of local variables.
Starting at position 1 (the second card in the deck), swap the card at i with the one at rand(i, 51). Note that you need rand(i, 51), NOT rand(1, 51). That won't ensure that each card is randomized.
Set deck[0] back to 0. Now the whole deck is shuffled except for the first card, so swap deck[0] with deck[rand(0, 51)] and you're done.

C# version:
public static void shuffle(int[] deck)
{
    while (deck[0] > 0)
        swap(ref deck[0], ref deck[deck[0]]);

    for (deck[0] = 1; deck[0] < 52; deck[0]++)
        swap(ref deck[deck[0]], ref deck[rand(deck[0], 51)]);

    deck[0] = 0;
    swap(ref deck[0], ref deck[rand(0, 51)]);
}

Javascript version:
while (deck[0] > 0)
    swap(0, deck[0]);

for (deck[0] = 1; deck[0] < 52; deck[0]++)
    swap(deck[0], rand(deck[0], 52));

deck[0] = 0;
swap(0, rand(0, 52));

...where swap(a, b) swaps deck[a] with deck[b].

Ruby, one line
Is this considered cheating? It should be as random as it gets.
deck=(0..51).to_a # fill the deck
deck[0..51] = (0..51).map{deck.delete_at(rand deck.length)}

(Ruby's rand method only takes one argument and then generates a number n such that 0 <= number < argument.)
Additionally - similar to sogart's Perl solution, but as far as I know it doesn't suffer from the problem:
deck = deck.sort_by{rand}

Ruby's sort_by is different than sort - it first generates the list of values to sort the array by, and only then sorts it by them. It's faster when it's expensive to find out the property we're sorting by, somewhat slower in all other cases. It's also useful in code golf :P

I wouldn't call it cheating, per se, but deck[0..51] does skirt the "no variables" rule somewhat by using a feature of the language. It's fair, I just think it loses some of the challenge. :) I don't know Ruby; can you explain the (0..51).map{deck.delete_at(rand deck.length)} part? Does that delete cards from deck?

@JustinMorgan yes, 52 times it deletes a random card from deck and adds it to the internal list of results that map is accumulating. Then when there's nothing left in deck the map result gets copied into deck. Basically there's a temporary, but it's a language feature rather than an explicit variable :)

deck.sort_by!{rand} is shorter.

JavaScript
NOTE: This solution is technically not correct because it uses a second parameter, i, in the call to shuffle, which counts as an external variable.
function shuffle(deck, i) {
    if (i <= 0)
        return;
    else {
        swap(deck[rand(0,i-1)], deck[i-1]);
        shuffle(deck, i - 1);
    }
}

Call with shuffle(deck,52)
A complete working example (had to modify swap slightly because there is no pass-by-reference of ints in JavaScript):
function rand(min, max) { return Math.floor(Math.random()*(max-min+1)+min); }
function swap(deck, i, j) {
    var t=deck[i];
    deck[i] = deck[j];
    deck[j] = t;
}

function shuffle(deck, i) {
    if (i <= 0)
        return;
    else {
        swap(deck, rand(0,i-1), i-1);
        shuffle(deck, i - 1);
    }
}

// create deck
var deck=[];
for(i=0;i<52;i++)deck[i]=i;
document.writeln(deck);
shuffle(deck,52);
document.writeln(deck);

Well done. What I had in mind was considering parameters of shuffle as variables, but I didn't specify that so +1. Nice use of recursion, too.

-1, doesn't generate all permutations, this is obvious because element 51 will never occupy it's original place, and because you only call rand enough to generate 51! permutations out of the possible 52!

@eBusiness: In the original spec, the deck is arbitrarily ordered, not necessarily in the order 1-52.  I just used that because it was the easiest.

@eBusiness: I modified to allow for the possibility of leaving the element in the same spot, by using deck[rand(0,i-1)] instead of deck[rand(0,i-2)].  Also swap all the way to i=0 instead of stopping at i=1.  Does that help?

Yup, that should do it, except that you now break the XOR swap specification.

C++
#include <cstdlib>
#include <ctime>
#include <iostream>

int deck[52];

void swap(int a, int b) {
    deck[a] ^= deck[b];
    deck[b] ^= deck[a];
    deck[a] ^= deck[b];
}

int r(int a, int b) {
    return a + (rand() % (b - a + 1));
}

void s(int *deck) {
    swap(1, r(2, 51));
    deck[0] *= 100;

    for(deck[0] += 2; (deck[0] % 100) < 51; deck[0]++) {
        swap(deck[0] % 100,
          r(0, 1) ? r(1, (deck[0] % 100) - 1) : r((deck[0] % 100) + 1, 51));
    }
    swap(51, r(1, 50));

    deck[0] = (deck[0] - 51) / 100;
    swap(r(1, 51), 0);
}

int main(int a, char** c)
{
    srand(time(0));

    for (int i = 0; i < 52; i++)
        deck[i] = i;

    s(deck);
    s(deck);

    for (int i = 0; i < 52; i++)
        std::cout << deck[i] << " ";
}

Avoids swapping elements with themselves, so has to call twice to be random.

swap(deck[rand(1, 51)], (deck[0] - 51) / 100); How will swap know where to put the second value? You're also missing a ).

Oops, thanks.  I started moving that part during a revision and must have got distracted before finishing it :P

Downvote wasn't from me, BTW. I'll test when I can.

OK.  I made it easier to test by providing a full program.

Very clever. My own solution used deck[0], but not in the way you have.

Got a chance to test this, and as I kind of suspected, the randomness isn't correct. Here it is using the B&W visualizer I posted: http://i51.tinypic.com/3484qy1.jpg. It should look more like this: http://i54.tinypic.com/14bjqlc.jpg. For one thing, it looks like you're swapping each card with all other cards in the deck, rather than each unswapped card. You're also treating the edges differently than the rest of the deck. See my link on the Fisher-Yates shuffle algorithm: http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle

D
shuffle(int[] d){
    while(d.length){
        if([rand(0,d.length-1)!=0)swap(d[0],d[rand(1,d.length-1)]);
        d=d[1..$];
    }
}

Another Perl solution, which actually produces uniformly distributed output:
sub shuffle_integers {
    map int, sort {$a-int $a <=> $b-int $b} map $_+rand, @_;
}

say join " ", shuffle_integers 1 .. 52;

This solution uses Perl's rand, which returns a random number x in the range 0 ≤ x < 1.  It adds such a random number to each integer in the input, sorts the numbers according to their fractional parts, and finally strips those fractional parts away again.
(I believe the use of the special variables $_, $a and $b falls within the spirit of the challenge, since those are how perl passes the input to map and sort, and they're not used for any other purpose in the code.  In any case, I believe they're actually aliases to the input values, not independent copies.  This is not actually an in-place shuffle, though; both map and sort create copies of the input on the stack.)

Java
I am surprised nobody stated the obvious:
(I'll assume swap(x,x) does nothing.
    static void shuffle(){
        swap(1,rand(0,1));
        swap(2,rand(0,2));
        swap(3,rand(0,3));
        swap(4,rand(0,4));
        swap(5,rand(0,5));
        swap(6,rand(0,6));
        swap(7,rand(0,7));
        swap(8,rand(0,8));
        swap(9,rand(0,9));
        swap(10,rand(0,10));
        swap(11,rand(0,11));
        swap(12,rand(0,12));
        swap(13,rand(0,13));
        swap(14,rand(0,14));
        swap(15,rand(0,15));
        swap(16,rand(0,16));
        swap(17,rand(0,17));
        swap(18,rand(0,18));
        swap(19,rand(0,19));
        swap(20,rand(0,20));
        swap(21,rand(0,21));
        swap(22,rand(0,22));
        swap(23,rand(0,23));
        swap(24,rand(0,24));
        swap(25,rand(0,25));
        swap(26,rand(0,26));
        swap(27,rand(0,27));
        swap(28,rand(0,28));
        swap(29,rand(0,29));
        swap(30,rand(0,30));
        swap(31,rand(0,31));
        swap(32,rand(0,32));
        swap(33,rand(0,33));
        swap(34,rand(0,34));
        swap(35,rand(0,35));
        swap(36,rand(0,36));
        swap(37,rand(0,37));
        swap(38,rand(0,38));
        swap(39,rand(0,39));
        swap(40,rand(0,40));
        swap(41,rand(0,41));
        swap(42,rand(0,42));
        swap(43,rand(0,43));
        swap(44,rand(0,44));
        swap(45,rand(0,45));
        swap(46,rand(0,46));
        swap(47,rand(0,47));
        swap(48,rand(0,48));
        swap(49,rand(0,49));
        swap(50,rand(0,50));
        swap(51,rand(0,51));
    }

OK, ok, it can be shorter:
package stackexchange;

import java.util.Arrays;

public class ShuffleDry1
{
    static int[] deck = new int[52];

    static void swap(int i, int j){
        if( deck[i]!=deck[j] ){
            deck[i] ^= deck[j];
            deck[j] ^= deck[i];
            deck[i] ^= deck[j];
        }
    }

    static int rand(int min, int max){
        return (int)Math.floor(Math.random()*(max-min+1))+min;
    }

    static void initialize(){
        for( int i=0 ; i<deck.length ; i++ ){
            deck[i] = i;
            swap(i,rand(0,i));
        }
    }

    static void shuffle(){
        while( deck[0]!=0 ) swap(0,deck[0]);
        for( deck[0]=52; deck[0]-->1 ; ) swap(deck[0],rand(deck[0],51));
        swap(0,rand(0,51));
    }

    public static void main(String[] args) {
        initialize();
        System.out.println("init: " + Arrays.toString(deck));
        shuffle();
        System.out.println("rand: " + Arrays.toString(deck));
    }

}

Burlesque
What you are actually asking for is a random permutation of a list of integers? r@ will give us all permutations, and we just select a random one.
blsq ) {1 2 3}r@sp
1 2 3
2 1 3
3 2 1
2 3 1
3 1 2
1 3 2
blsq ) {1 2 3}r@3!!BS
2 3 1

Since we need true randomness, something Burlesque isn't capable of doing because Burlesque has no I/O functionality you'd need to provide some source of randomness through STDIN.
That's probably something I'll fix in later version (i.e. generate a random seed at startup and push it to the secondary stack or something like that, but the Burlesque Interpreter itself has no I/O).

Javascript
I'm not sure if it's "cheating" but my solution uses the native local array of a function's arguments. I included my self-made functions of rand() swap() and filldeck(). Of interesting note, this should work with a deck of any size.
    var deck = [];

    function shuffle(){
        main(deck.length);
    }

    function main(){
        arguments[0] && swap( arguments[0]-=1, rand(0, deck.length-1) ), main(arguments[0]);
    }

        function rand(min, max){
            return Math.floor( Math.random()*(max-min+1) )+min;
        }

        function swap(x, y){
            var _x = deck[x], _y = deck[y];
            deck[x] = _y, deck[y] = _x;
        }

        function filldeck(dL){
            for(var i=0; i<dL; i++){
                var ran = rand(1,dL);
                while( deck.indexOf(ran) >= 0 ){
                    ran = rand(1,dL);
                }
                deck[i] = ran;
            }
        }

    filldeck(52);
    shuffle();

It is cheating, I think. However, it's very clever cheating, so nice job.

Tcl, 32 bytes
Abusing time function which serves to measure how much time is spent a script is running, but also can serve as a looping mechanism without declaring any variables.
time {lswap $D [rand] [rand]} 52

Try it online!

Am I correct that this only performs 52 random swaps? That's not enough for a true shuffle. I ran it a few times and counted an average of 8 cards still in their starting positions, and the probability of that with a true shuffle is about 9x10^-6.

@JustinMorgan: Can you please explain me better the probability calculation?

perl - this is not a proper shuffle as explained in comments!
my @deck = (0..51);
@deck = sort {rand() <=> rand()} @deck;
print join("\n",@deck);

I think I didn't use anything as a swap etc. was that needed as part of the problem?

That would work if sorting by a random function was a way of producing an even random distribution. However it is not. -1

and why is it not? could you give me a link to read???

The quality of the result will vary greatly depending on the sort algorithm, but in almost all cases the result will be very far from an equal distribution random function. Here is an article on the subject: http://sroucheray.org/blog/2009/11/array-sort-should-not-be-used-to-shuffle-an-array/

JavaScript 4 lines
function shuffle() {
  while(deck[0]!=0)swap(deck[0],rand(1,51))
  while(deck[0]++!=104)swap(deck[0]%51+1,rand(1,51))
  deck[0]=0
  swap(0,rand(0,51))
}

Original answer that wasn't random enough.  The swap wasn't guaranteed to touch each item in the deck.
// shuffle without locals
function shuffle() {
  deck.map(function(){swap(deck[rand(0,51)],deck[rand(0,51)])});
}

Doesn't produce a true random shuffle. Here's a visualizer test: http://jsfiddle.net/muk1bthm/. I changed your shuffle code slightly to match my swap implementation, but here it is verbatim: http://jsfiddle.net/m7km4u6g/

To clarify, the above comment applies to the new version, which still isn't random.


text:
Decompose a permutation into cycles
There is a well-known theorem that any permutation can be decomposed into a set of cycles.  Your job is to write the shortest possible program to do so.
Input:
Two lines.  The first contains a number N, the second contains N distinct integers in the range [0,N-1] separated by spaces.  These integers represent a permutation of N elements.
Output:
One line for each cycle in the permutation.  Each line should be a space-separated list of integers in cycle order.
Cycles can be output in any order, and each cycle can be output starting at any position.
Example 1:
8
2 3 4 5 6 7 0 1

This input encodes the permutation 0->2, 1->3, 2->4, 3->5, 4->6, 5->7, 6->0, 7->1.  This decomposes into cycles like this:
0 2 4 6
1 3 5 7

An equally valid output would be
5 7 1 3
2 4 6 0

Example 2:
8
0 1 3 4 5 6 7 2

valid output:
0
1
4 5 6 7 2 3

@Keith What is the maximum value of N?

3 chars in J :>C.

Let's say N<1000.

Permutations are usually counted up from 1, not 0.

Mathematicians count from 1, computer scientists count from 0 :)

@Keith I count from 42 by exponential increasing increments.

Nice problem, I thought of adding this one before but never got the right opportunity.Thanks :-)

I now remove my 38 chars solution.

What is the point of having N in the input ?

@Evpok: it's there in case it helps.  No need to use it.

C 145 134 Characters
N,A[999],i,j,f;main(){gets(&i);for(;~scanf("%d",A+N);)N++;for(;j<N;j++,f=f&&!puts(""))while(i=A[j]+1)f=printf("%d ",j),A[j]=-1,j=--i;}

http://www.ideone.com/BrWJT

Is it legal to call implicitly declared variadic functions? Is it legal to omit first int?

It is legal to do anything as long as the code works. While it may give warnings, as long as it does not give errors, it should be Ok.

The very point is in the meaning of "works". Anyway I've added an answer (139 chars) that uses this rule (i.e. where "works" means "there is at least one self-declared C compiler in which, apparently, the generated machine code works")

+1: I like the gets(&i) idea to get rid of that useless first line, however this clearly wouldn't work on 16-bit systems if more than 10 elements are passed. But once again if the rules are "finding at least a program that claims to be a C compiler that creates an executable where in at least one case seems - at least to me - to give a valid response" then this is an improvement :-)

Python 131 chars
input();d=dict((i,int(x))for i,x in enumerate(raw_input().split()))
while d:
 x=list(d)[0]
 while x in d:print x,;x=d.pop(x)
 print

the ending newline is not needed

J (between 2 and 32)
I'm not quite clear on i/o format, but I think C. would do, if the following output would be accepted:
   C. 0 1 3 4 5 6 7 2
┌─┬─┬───────────┐
│0│1│7 2 3 4 5 6│
└─┴─┴───────────┘

(It looks better in the J terminal.)
If it needs to be a named function that complies to my best understanding of the i/o format, that'd be 32 characters, of which 30 are for output format conversion...
g=:>@(":L:0)@(C.@".@}.~>:@i.&LF)

In action:
   g=:>@(":L:0)@(C.@".@}.~>:@i.&LF)
   g
>@(":L:0)@(C.@".@}.~ >:@i.&(10{a.))
   t
8
0 1 3 4 5 6 7 2
   g t
0
1
7 2 3 4 5 6

Explanation:
J is executed from right to left (practically). @ is a 'function' (not technically a function, but that's close enough) to combine functions.

i.&LF - find the first index of LF, a predefined variable
containing ASCII character number 10, the line feed.
>: - find the first LF, and increment it's index by one. We don't actually want the linefeed, we want the array that follows it.
}.~ - Selects the part of the input that we want.
". - Since the input format is valid J (*\õ/*) we can just use the eval verb (I know it's not actually called eval.) to turn it into an array
C. - Pure magic. I really have no idea what this does, but it seems to work!
":L:0 - Representation. Turns the output of C. into a boxed sequence of strings
> - Unbox. The actual output is actually a string array (there are spaces behind the first to numbers of the example).

Haskell, 131 characters
n%l|all(>n)l=(n:l>>=(++" ").show)++"\n"|1<3=""
c(_:a)=a>>=(\n->n%(takeWhile(/=n)$iterate(a!!)$a!!n))
main=interact$c.map read.words

Edit: (135 -> 131) >= became >, eliminated two tail calls though pattern matching & pre-application of a!!.

C (sort of), 139 chars
n,j,t,a[999];main(){scanf("%*i");for(;scanf("%i",a+n)>0;)n++;while(n--)if(a[j=n]+1){for(;t=a[j]+1;a[j]=-1,j=t)printf("%i ",--t);puts("");}}

The final newline is not included.
I said "sort-of" because AFAIK for example

it's not legal to omit declaration for variadic functions (ANSI C89: 3.3.2.2)
int cannot be omitted for variable declaration (I didn't find where it's said it can be omitted and implicit type declaration is only described for functions. The grammar specification in the standard is basically useless as accepts much more than valid C declarations, for example double double void volatile x;)
a newline at the end of a non-empty source file is mandatory (ANSI C89: A.6.2)

but the above code compiled with gcc -ocycles cycles.c apparently works anyway.

This is a valid C program,but this is not C99.

@Debanjan: No it's not ANSI C (not even 89). For example the standard says (3.3.2.2) that if a function uses a variable number of arguments then it cannot be declared implicitly at the function call site (in other words you cannot call scanf without #include <stdio.h> even if the parameters are correct and do not require conversions): <<If the function is defined with a type that includes a prototype, and the types of the arguments after promotion are not compatible with the types of the parameters, or if the prototype ends with an ellipsis ( ", ..." ), the behavior is undefined.>>

Clojure, 145
(let[v(vec(repeatedly(read)read))](loop[a(set v)b 0](cond(a(v b))(do(print" "b)(recur(disj a(v b))(v b)))(seq a)(do(prn)(recur a(first a)))1"")))

Somewhat ungolfed, and broken out into a function (input must be a vector, which is what (vec(repeatedly(read)read)) from above produces):
(defn p [v]
  (loop [a (set v) b 0]
    (cond
     (a (v b)) (do (print" "b) (recur (disj a (v b)) (v b)))
     (seq a) (do (prn) (recur a (first a)))
     1 "")))

(Wow, just noticed this challenge is over 3 year old. Oh well, had fun doing it anyways!)

Jelly, 17 bytes
ḲVJ’,Ɗy¥Ƭ`ZṢ€Q€QG

Try it online!
or with modern I/O standards, 14 bytes.
Takes N on STDIN and the list of numbers as the first command line argument
The last 5 bytes feel far too long for such a simple task
How it works
ḲVJ’,Ɗy¥Ƭ`ZṢ€Q€QG - Main link. Takes a string S on the left
Ḳ                 - Split S on spaces
 V                - Evaluate each element. Call this list of integer L
       ¥          - Group the previous 2 links into a dyad f(A, L):
     Ɗ            -   Group the previous 3 links into a monad g(A):
  J               -     Length range of A
   ’              -     Decrement to use 0 indexing
    ,             -     Pair with A
      y           -   Transliterate L using the mapping from g(A)
        Ƭ         - While results are unique, repeatedly apply f(A, L),
         `        -  starting with f(L, L)
          Z       - Transpose
           Ṣ€     - Sort each subarray
             Q€   - Deduplicate each subarray
               Q  - Deduplicate the whole array
                G - Join each subarray with spaces and the subarrays by newlines

JavaScript (Node.js), 110 bytes
(n,N=[])=>n.flatMap(e=>~N.indexOf(e)?[]:[(U=(T,P=T[T.length-1])=>N.push(P)&&(e==n[P]?T:U([...T,n[P]])))([e])])

Try it online!
This is the version which takes in a list of integers and outputs a 2d list, where each sublist is a cycle.
This version takes in the number of numbers (not used). The numbers are taken as a space-separated string, and the function returns a string formatted as described in the question. It is 141 bytes long.

JavaScript (Node.js), 59 bytes
x=>x.flatMap(g=a=>1/x[a]?[[a,...g(x[a],x[a]=g)[0]||[]]]:[])

Try it online!
JavaScript (Node.js), 60 bytes
x=>x.flatMap(g=a=>[1/x[a]?[a,...g(x[a],delete x[a])[0]]:[]])

Try it online!

Wolfram Language (Mathematica), 46 bytes
Needs["Combinatorica`"];Combinatorica`ToCycles

Complete code with test cases is:
Needs["Combinatorica`"];
Combinatorica`ToCycles /@
{
 {3, 4, 5, 6, 7, 8, 1, 2},
 {1, 2, 4, 5, 6, 7, 8, 3},
 {1, 2, 3},
 {1 , 2 , 4 , 5 , 6, 7 , 8, 3}
}
// Grid

$$
\left(
\begin{array}{ccc}
 \{3,5,7,1\} & \{4,6,8,2\} & \text{Null} \\
 \{1\} & \{2\} & \{4,5,6,7,8,3\} \\
 \{1\} & \{2\} & \{3\} \\
 \{1\} & \{2\} & \{4,5,6,7,8,3\} \\
\end{array}
\right)
$$

Needs["Combinatorica`"] -> <<Combinatorica`

Python3.8, 129 chars
def v(i):_=a[i];a[i]=-1;return~_ and[i]+v(_)or[]
input()
for i in range(len(a:=[*map(int,input().split())])):~a[i]and print(v(i))

MATL, 20 bytes
:wQy"yy)]v"@quS!]Xhu

Try it out!
Takes the liberty of assuming the second input is inside a pair of square brackets, but otherwise sticks to the requirements (spending 2 bytes on the 0-indexing for example). Works pretty similar to caird coinheringaahing's Jelly answer.

source: Stack Exchange

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

authors: وسيم علي حسن الروبي

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

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

sort: votes


text:
A subset of Verbal arithmetic
Implement a verbal arithmetic solver of several same sequence of numbers added together:
  TWO
+ TWO
-----
 FOUR

  REPEAT
  REPEAT
  REPEAT
+ REPEAT
--------
 ANDSTOP

  SPEED
+ SPEED
-------
  KILLS

There are some restrictions: each letter should represent different digits, and no letter can be zero.
Implement the solver as a function of the operands, the sum and number of repetitions returns a list of solutions (solution: the tuple of resulting operand and sum). For example:
f(['T','W','O'], ['F','O','U','R'], 2) == [(734, 1468)]

You do not need to represent variables as letters, and you do not need to use a hash in the solution.
Brute-force search allowed.
Shortest code wins.

Can you give a sample solution for the other two cases?

SPEED:= 29331, 58662:= KILLS, code follows, needs to be golfed.

Mathematica
Spaces added for clarity. Not much golfed.
Need to use greek letters because the input letters are treated as symbols.
F[σ_ ,ρ_ ,τ_]:=
 (φ = FromDigits;
 Rest@Union[
   If [ τ * φ@σ == φ@ρ, {φ@σ,φ@ρ} ] /.#& /@
 (Thread[Rule[ σ ∪ ρ , # ] ] & /@ Permutations[Range@9, {Length[σ ∪ ρ] }])])

Usage:
F[{r,e,p,e,a,t},{a,n,d,s,t,o,p},3]
{{819123,2457369}}

F[{s,p,e,e,d},{k,i,l,l,s},3]
{}

F[{t,w,o},{f,o,u,r},2]
{{734,1468},{836,1672},{846,1692},{867,1734},{928,1856},{938,1876}}

It didn't find any solution for the SPEED+SPEED+SPEED = KILLS ... is that a bug?
Edit
Allowing zero, it finds the following solutions for the SPEED+SPEED+SPEED = KILLS equation:
{{10887,32661},{12667,38001},{23554,70662},
 {23664,70992},{25334,76002},{26334,79002}}

Edit
According to comment:
F[{s, p, e, e, d}, {k, i, l, l, s}, 2]

{{21776,43552},{21886,43772},{23556,47112},{27331,54662},
 {29331,58662},{42667,85334},{45667,91334},{46557,93114}}

meta-comment ... Is there a way to show greek letters in code blocks?

EDIT: the one shown on the paper has only two SPEED's

belisarius: Th trick is not to use HTML escapes. Since those represent only characters using characters directly is not forbidden ;-). You may have to fix your indenting, though; I'm not sure I kept that correct.

@Joey The escaped chars are not used in Mathematica source, I used them just for rendering here. But it seems not all browsers render the chars equal. I see your code and mine exactly the same :)

Python
def f(A,B,N):
 D={}
 r=[]
 for j in A:D[j]=0
 for j in B:D[j]=0
 x=len(D)
 for i in xrange(10**(x-1),10**x):
        c=str(i)
        s={}
        for j in c:s[j]=0
        if(len(s)-x or '0' in c):continue
        k=P=Q=0
        for j in D:D[j]=int(c[k]);k+=1
        for j in A:P=P*10+D[j]
        for j in B:Q=Q*10+D[j]
        if(P*N==Q):r.append((P,Q))
 return r
print f(['T','W','O'], ['F','O','U','R'], 2)

http://ideone.com/4wIQe

scala:  333  289
type S=String
def d(x:S,m:Map[Char,Int])={var s=0
for(c<-x;k=m.find(_._1==c);v=(k.get)._2){s*=10
s+=v}
s}
def s(t:Int,f:S,p:S):Unit={
def c(m:Map[Char,Int])=d(f,m)*t==d(p,m)
val g=f.toSet++p
val m=g.zip(util.Random.shuffle((1 to 9).toSeq).take(g.size))
if(c(m.toMap))print(m)else s(t,f,p)}

Usage:
s (2,"SPEED","KILLS")
Set((D,7), (K,8), (I,5), (E,6), (S,4), (L,3), (P,2))

s(4,"REPEAT","ANDSTOP")
// endless loop :)

PHP (200)
This function takes a very long time to execute and uses lots of memory, but it satisfies the criteria.
function f($o,$s,$n){$w=count_chars(($c=join($o)).$d=join($s),3);while(++$i<pow(10,9)){if(($u=count_chars($i,3))&&$u[0]*$u[8]&&($n*$a=strtr($c,$w,$i))==$b=strtr($d,$w,$i))$x[]=array($a,$b);}return$x;}

Sample usage:
$a=array('T','W','O');
$b=array('F','O','U','R');
$c=f($a, $b, 2); // returns an array of tuples that satisfy the equation

Un-golfed explanation:
function solve($operand, $sum, $num) {
  // convert the operand and sum arrays into strings, join them, then get a string containing the unique characters
  $operand_string = join($operand);
  $sum_string = join($sum);
  $unique_chars = count_chars($operand_string . $sum_string, 3);

  // loop from 1 to 10^9
  while (++$i < pow(10,9)) {
    // get the unique digits in $i
    $unique_digits = count_chars($i, 3);
    // check whether the first digit is non-zero (count_chars sorts in ascending order)
    // and whether the ninth digit is non-zero, these conditions guarantee that $i
    // is a permutation of 1...9
    if ($u[0] * $u[8]) {
      // translate the operand and sum into numbers, then check if the operand * num = sum
      $translated_operand = strtr($operand_string, $unique_chars, $i);
      $translated_sum = strtr($sum_string, $unique_chars, $i);
      if ($num * $translated_operand == $translated_sum) {
        // add the solution to the solutions array
        $solutions[] = array($translated_operand, $translated_sum);
      }
    }
  }
  // return the solutions array
  return $solutions;
}

If we're allowed to input the operand and sum as strings instead of arrays, then I can skip the join operations and save 20 characters to put the total at 180.

05AB1E, 24 bytes
žhœï²JÙ©gδ£εUε®X‡].Δ`¹*Q

Takes two loose inputs, the first being the integer and the second as a pair of words (i.e. first input = 4, second input = ["ANDSTOP","REPEAT"]).
Try it online. Brute-force approach, so unfortunately it's extremely slow; it's barely able to output the result for the first test case in ~45 seconds on TIO.
Explanation:
žh       # Push builtin "0123456789"
  œ      # Get all 3628800 (10!) permutations of this string of digits
   ï     # Cast each to an integer to remove leading 0s from some items
         # (otherwise ["0264","132"] would be the output for the first test case)
²        # Push the second input-pair
 J       # Join them together
  Ù      # Uniquify the letters
   ©     # Store it in variable `®` (without popping)
    g    # Pop and push its length to get the amount of unique letters
     δ   # For each permutation:
      £  #  Only keep the first unique-length amount of digits
ε        # Map each shortened string of digits to:
 U       #  Pop and store the current string of digits in variable `X`
  ε      #  Map over the two words of the (implicit) second input-pair
   ®     #   Push the unique letters from variable `®`
    X    #   Push the current digits we're mapping over from variable `X`
     ‡   #   Transliterate the letters to digits in the input-string we're mapping over
]        # Close the nested maps
 .Δ      # Find the first pair of integers which is truthy for:
   `     #  Pop and push them separated to the stack
    ¹*   #  Multiply the second (top) value by the first input
      Q  #  And check if it's now equal to the first value
         # (after which the result is output implicitly)

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


text:
An Old Irish Blessing
I don't know who coined these words, and I'm not Irish, but I give you an Irish blessing:
May the road rise up to meet you
May the wind be always at your back
May the sun shine warm upon your face
The rains fall soft upon your fields
And until we meet again
May God hold you in the hollow of His hand

I was planning on posting this a few weeks from now, but it just dawned on me that yesterday was Saint Patrick's Day.
Rules:

Produce the above text exactly.
(Feel free to break this rule for the sake of cleverness and amusement.)
The program must generate the text on its own accord.  cat is not a valid solution.
The solution with the fewest characters "wins".

I saw slight variations in wording among versions of the blessing I obtained from the Internet, so I tried to average them out.  Please use the version posted above.  Also, I dropped the punctuation to make it a bit easier.
May the luck of the Irish enfold you.

05AB1E, 117 115 bytes
'€¿“‡âŽÓ€î€†€€èÊ€‚“„€Ë‡´).ª“€¿€€†â£ƒ€¾€„‰Ã€î““€¿€€ïë€ï‡Š€›€ž‚ƒ““€¿€€‡µã»©ÃˆÉ€žŠÑ““€€¥·sŽ§š¼ˆÉ€ž™æ““€ƒ‡æ€¦‰Ã†î“).ªÀ»

Try it online!
Thanks to Kevin Cruijssen for -2 bytes
'€¿                 "may"
“‡âŽÓ€î€†€€èÊ€‚“    "god hold you in the hollow of"
„€Ë‡´               "his hand"
)                   push stack into a list
.ª                  sentence-case each
“€¿€€†â£ƒ€¾€„‰Ã€î“  "may the road rise up to meet you"
“€¿€€ïë€ï‡Š€›€ž‚ƒ“  "may the wind be always at your back"
“€¿€€‡µã»©ÃˆÉ€žŠÑ“  "may the sun shine warm upon your face"
“€€¥·sŽ§š¼ˆÉ€ž™æ“   "the rains fall soft upon your fields
“€ƒ‡æ€¦‰Ã†î“        "and until we meet again"
)                   push stack into a list
.ª                  sentence-case each
À                   rotate list left
»                   join by newlines
                    implicitly print

You can remove the ðý for -2. The final » will join each inner list by spaces before joining by newlines implicitly.

Ah, that's nice to know. Thank you.

Python, 143 chars
#coding:u8
print u'慍⁹桴潲摡爠獩灵琠敭瑥礠畯䴊祡琠敨眠湩敢愠睬祡⁳瑡礠畯⁲慢正䴊祡琠敨猠湵猠楨敮眠牡灵湯礠畯⁲慦散吊敨爠楡獮映污潳瑦甠潰潹牵映敩摬ੳ湁湵楴敷洠敥⁴条楡੮慍⁹潇潨摬礠畯椠桴潨汬睯漠楈⁳慨摮'.encode("u16")[2:]

run at codepad.org

Haskell, 179 characters
e="\n "++['='..'z']++e;i r=[e!!div r 64,e!!r]
main=putStr$i.fromEnum=<<"뒦뾁빭몁뷴릩끷뮸몁뺵끹봁벪몹끾봺뀒릾끹뭪끼뮳멁맪끦뱼릾븁릹끾봺뷁맦먰뀒릾끹뭪끸뺳끸뭮볪끼릷벁뺵봳끾봺뷁뫦먪뀙뭪끷릮본끫릱뱁븴뫹끺뵴볁뾴뺷끫뮪뱩븀놳멁뺳빮뱁뼪끲몪빁리릮변뒦뾁댴멁뭴뱩끾봺끮볁빭몁뭴뱱봼끴뫁덮븁뭦볩뀀"

This exploits the ancient common bond between the Irish and the Koreans. You all knew that lace and potato farming came via Korea, and that Kimchi was first made in Dublin... right?

Edit: (197 -> 184) No need to mod (why⁈ :-) ); eliminated separate declaration for the Korean text.
Edit: (184 -> 179) Used a more compact to represent code book.

Hahaha, nice!  That's why I'm usually careful to say "solution with the fewest characters" (I edited my post accordingly).  Exploiting Unicode is always an option, but few people take it.

Isn't it possible to put three our four chars into one exploiting this way?

@FUZxxl: You have to be careful: Not all values in the range 0x0 ~ 0x10FFFF are usable. Some are outright banned (0xD800 ~ 0xDFFF for example and any value ending in FFFE or FFFF), others may or may not be legal in a given programming language's lexical definition.  I choose Hangul here because it is a large block of values with no holes, and all certainly legal in any definition of Unicode string. But, it is only ~13 bits in size.

MtnViewMark: If you have two consecutive surrogates then it is indeed valid and would be a single codepoint outside the BMP. That would require that the implementation uses UTF-16 and could cut your character needs by one ;)

@Joey - You could only use surrogates if every appearance of them were paired, and in proper order (one from 0xD800~0xDBFF and the next from 0xDC00~0xDFFF). But, in Haskell's case it is moot: String is a sequence of unicode scalar values (U+0000 ~ U+D7FF & U+E000 ~ U+10FFFF), not UTF-16 code units. Note that fromEnum returns the character's code point scalar value, not some encoded value.

INTERCALL, 3421 bytes
A simple solution.
Genered automatically, if anyone is wondering...
INTERCALL IS A ANTIGOLFING LANGUAGE
SO THIS HEADER IS HERE TO PREVENT GOLFING IN INTERCALL
THE PROGRAM STARTS HERE:
PUSH LXXVII
PRINT
PUSH XCVII
PRINT
PUSH CXXI
PRINT
PUSH XXXII
PRINT
PUSH CXVI
PRINT
PUSH CIV
PRINT
PUSH CI
PRINT
PUSH XXXII
PRINT
PUSH CXIV
PRINT
PUSH CXI
PRINT
PUSH XCVII
PRINT
PUSH C
PRINT
PUSH XXXII
PRINT
PUSH CXIV
PRINT
PUSH CV
PRINT
PUSH CXV
PRINT
PUSH CI
PRINT
PUSH XXXII
PRINT
PUSH CXVII
PRINT
PUSH CXII
PRINT
PUSH XXXII
PRINT
PUSH CXVI
PRINT
PUSH CXI
PRINT
PUSH XXXII
PRINT
PUSH CIX
PRINT
PUSH CI
PRINT
PUSH CI
PRINT
PUSH CXVI
PRINT
PUSH XXXII
PRINT
PUSH CXXI
PRINT
PUSH CXI
PRINT
PUSH CXVII
PRINT
PUSH X
PRINT
PUSH LXXVII
PRINT
PUSH XCVII
PRINT
PUSH CXXI
PRINT
PUSH XXXII
PRINT
PUSH CXVI
PRINT
PUSH CIV
PRINT
PUSH CI
PRINT
PUSH XXXII
PRINT
PUSH CXIX
PRINT
PUSH CV
PRINT
PUSH CX
PRINT
PUSH C
PRINT
PUSH XXXII
PRINT
PUSH XCVIII
PRINT
PUSH CI
PRINT
PUSH XXXII
PRINT
PUSH XCVII
PRINT
PUSH CVIII
PRINT
PUSH CXIX
PRINT
PUSH XCVII
PRINT
PUSH CXXI
PRINT
PUSH CXV
PRINT
PUSH XXXII
PRINT
PUSH XCVII
PRINT
PUSH CXVI
PRINT
PUSH XXXII
PRINT
PUSH CXXI
PRINT
PUSH CXI
PRINT
PUSH CXVII
PRINT
PUSH CXIV
PRINT
PUSH XXXII
PRINT
PUSH XCVIII
PRINT
PUSH XCVII
PRINT
PUSH XCIX
PRINT
PUSH CVII
PRINT
PUSH X
PRINT
PUSH LXXVII
PRINT
PUSH XCVII
PRINT
PUSH CXXI
PRINT
PUSH XXXII
PRINT
PUSH CXVI
PRINT
PUSH CIV
PRINT
PUSH CI
PRINT
PUSH XXXII
PRINT
PUSH CXV
PRINT
PUSH CXVII
PRINT
PUSH CX
PRINT
PUSH XXXII
PRINT
PUSH CXV
PRINT
PUSH CIV
PRINT
PUSH CV
PRINT
PUSH CX
PRINT
PUSH CI
PRINT
PUSH XXXII
PRINT
PUSH CXIX
PRINT
PUSH XCVII
PRINT
PUSH CXIV
PRINT
PUSH CIX
PRINT
PUSH XXXII
PRINT
PUSH CXVII
PRINT
PUSH CXII
PRINT
PUSH CXI
PRINT
PUSH CX
PRINT
PUSH XXXII
PRINT
PUSH CXXI
PRINT
PUSH CXI
PRINT
PUSH CXVII
PRINT
PUSH CXIV
PRINT
PUSH XXXII
PRINT
PUSH CII
PRINT
PUSH XCVII
PRINT
PUSH XCIX
PRINT
PUSH CI
PRINT
PUSH X
PRINT
PUSH LXXXIV
PRINT
PUSH CIV
PRINT
PUSH CI
PRINT
PUSH XXXII
PRINT
PUSH CXIV
PRINT
PUSH XCVII
PRINT
PUSH CV
PRINT
PUSH CX
PRINT
PUSH CXV
PRINT
PUSH XXXII
PRINT
PUSH CII
PRINT
PUSH XCVII
PRINT
PUSH CVIII
PRINT
PUSH CVIII
PRINT
PUSH XXXII
PRINT
PUSH CXV
PRINT
PUSH CXI
PRINT
PUSH CII
PRINT
PUSH CXVI
PRINT
PUSH XXXII
PRINT
PUSH CXVII
PRINT
PUSH CXII
PRINT
PUSH CXI
PRINT
PUSH CX
PRINT
PUSH XXXII
PRINT
PUSH CXXI
PRINT
PUSH CXI
PRINT
PUSH CXVII
PRINT
PUSH CXIV
PRINT
PUSH XXXII
PRINT
PUSH CII
PRINT
PUSH CV
PRINT
PUSH CI
PRINT
PUSH CVIII
PRINT
PUSH C
PRINT
PUSH CXV
PRINT
PUSH X
PRINT
PUSH LXV
PRINT
PUSH CX
PRINT
PUSH C
PRINT
PUSH XXXII
PRINT
PUSH CXVII
PRINT
PUSH CX
PRINT
PUSH CXVI
PRINT
PUSH CV
PRINT
PUSH CVIII
PRINT
PUSH XXXII
PRINT
PUSH CXIX
PRINT
PUSH CI
PRINT
PUSH XXXII
PRINT
PUSH CIX
PRINT
PUSH CI
PRINT
PUSH CI
PRINT
PUSH CXVI
PRINT
PUSH XXXII
PRINT
PUSH XCVII
PRINT
PUSH CIII
PRINT
PUSH XCVII
PRINT
PUSH CV
PRINT
PUSH CX
PRINT
PUSH X
PRINT
PUSH LXXVII
PRINT
PUSH XCVII
PRINT
PUSH CXXI
PRINT
PUSH XXXII
PRINT
PUSH LXXI
PRINT
PUSH CXI
PRINT
PUSH C
PRINT
PUSH XXXII
PRINT
PUSH CIV
PRINT
PUSH CXI
PRINT
PUSH CVIII
PRINT
PUSH C
PRINT
PUSH XXXII
PRINT
PUSH CXXI
PRINT
PUSH CXI
PRINT
PUSH CXVII
PRINT
PUSH XXXII
PRINT
PUSH CV
PRINT
PUSH CX
PRINT
PUSH XXXII
PRINT
PUSH CXVI
PRINT
PUSH CIV
PRINT
PUSH CI
PRINT
PUSH XXXII
PRINT
PUSH CIV
PRINT
PUSH CXI
PRINT
PUSH CVIII
PRINT
PUSH CVIII
PRINT
PUSH CXI
PRINT
PUSH CXIX
PRINT
PUSH XXXII
PRINT
PUSH CXI
PRINT
PUSH CII
PRINT
PUSH XXXII
PRINT
PUSH LXXII
PRINT
PUSH CV
PRINT
PUSH CXV
PRINT
PUSH XXXII
PRINT
PUSH CIV
PRINT
PUSH XCVII
PRINT
PUSH CX
PRINT
PUSH C
PRINT
END

Wow

GolfScript (204 chars)
Contains non-printing characters, so copy-paste may not work:
:k'May the road rise up to meet you
wind be always ar back¢ sun shin¬armÈon€face
Tåainsll soft¡ields
Aäuntil we meet ag²áGod holdø inñlow of His hand'{k{{k$}*0:k;}{127.2$<{-:k}*;}if}/](+

Base64-encoded:
OmsnTWF5IHRoZSByb2FkIHJpc2UgdXAgdG8gbWVldCB5b3UKnwh3aW5kIGJlIGFsd2F5cyBhnAVy
IGJhY2uiCXN1biBzaGlurANhcm3IA29upAZmYWNlClTlBGFpbnONA2xsIHNvZnShDGllbGRzCkHk
A3VudGlsIHdlIG1lZXQgYWeyA+EFR29kIGhvbGT4BCBpbvEFjgNsb3cgb2YgSGlzIGhhbmQne2t7
e2skfSowOms7fXsxMjcuMiQ8ey06a30qO31pZn0vXSgr

There really is less redundancy than you might expect in the string. I think gzip's savings are 2/3 from Lempel-Ziv and 1/3 from the Huffman encoding; what I'm using is essentially LZ, but I have more overhead than the gzip format.
Note that this is the first solution to take fewer bytes than the output.

PHP, 431 425 bytes
<?php $s="May therodisupm\nwnblckfTAgGH";$p=array('01234563','3cd8h328c73m','jj','3e6643');$b=str_split('s781937ab63cd348v28cfsgah93i631jg12b314328c73i1klfsbch3b5ah63g17et1k6fn56371ahb3m1u3b8m4ta6j9bfoh93ch4aj3g6v1p1ahf0123q89358j9328c3ah3456358u8g38m3rab351h9');foreach($b as $x){$x=b($x);if($x>27){$c=str_split($p[$x-28]);foreach($c as $y){echo $s[b($y)];}}else{echo $s[$x];}}function b($a){return base_convert($a,36,10);}

An approach of mapping and base conversion to store the information. However, I failed at keeping the program size very small.

Bash/Sed, 206 chars
I didn't manage to beat Peter Taylor, but like his solution, it's fewer bytes than the original. But I didn't use unprintable characters.
sed was useful in the similar "no strangers to codegolf" challenge. But there I used it twice, to compress the list of replacements. Here, the text is too short for this trick.
sed 's/Z/May the /;s/W/ uponYr f/;s/Y/ you/'<<X
Zroad rise up to meetY
Zwind be always atYr back
Zsun shine warmWace
The rains fall softWields
And until we meet again
May God holdY in the hollow of His hand

Haskell - 284
s n=words"And God His May The again always at back be face fall fields hand hold hollow in meet of rains rise road shine soft sun the to until up upon warm we wind you your"!!(fromEnum n-48)
main=mapM_(putStrLn.unwords.map s)$words"3IEDLJAQ 3IP967R8 3IHFNMR: 4C;GMR< 0KOA5 31>Q@I?B2="

Sadly, this is much longer than the output or putting the string verbatim.  Even the string literals themselves (without quotes) total to two characters longer than the input.  How can that be?

Quetzalcoatl, 218 bytes
"May the road rise up to meet you\nMay the wind be always at your back\nMay the sun shine warm upon your face\nThe rains fall soft upon your fields\nAnd until we meet again\nMay God hold you in the hollow of His hand"

Strings are implicitly printed.
Or pyth, 217 bytes
"May the road rise up to meet you\nMay the wind be always at your back\nMay the sun shine warm upon your face\nThe rains fall soft upon your fields\nAnd until we meet again\nMay God hold you in the hollow of His hand

Keg, 175 chars
‘3p‘®m‘00‘®t¶©m  ©t  2½;4•;up to 2m;you\n©m  ©t  2⬩;be 0Ȧ;at 0B;0∞;\n©m  ©t  sun kƝ;4Ȧ;0M;0B;0Ƚ;\nThe A④;2÷;4l;0M;0B;8R;\nAnd 0;we 2m;0¡;\n©m  God 1④;you in ©t  dɅ;of His 0║;

Thank goodness all long words are in Keg's dictionary. Just uses string compression to reduce length.
TIO currently doesn't work as it needs to be updated.
Try it online!

Wren, 248 bytes
Adopting this method.
System.print("Zroad rise up to meetY\nZwind be always atYr back\nZsun shine warmWace\nThe rains fall softWields\nAnd until we meet again\nMay God holdY in the hollow of His hand".replace("Z","May the ").replace("W"," uponYr f").replace("Y"," you"))

Try it online!

FEU, 200 bytes
a/1road rise up to meet3\n1wind be always at3r back\n1sun shine warm2ace\nThe rains fall soft2ields\nAnd until we meet again\nMay God hold3 in the hollow of His hands
m/1/May the /2/ upon3r f/3/ you/g

Try it online!
Is everyone sure there isn't a better replacement compression?


text:
What can you do in a 4k data URI?
Bounty is over, thephpdeveloper wins with Conway's Game of Life
The web platform today is advancing at a rapid rate. Features like CSS3 animations, transforms, drop shadows and gradients, <canvas>, <audio> and <video> tags, SVG, WebGL,  and many more mean that you can do far more in the browser, and in far less code, than ever before. Of course, many developers don't get to use those new features, because the sites and applications they work on need to be backwards compatible with ancient, moth-eaten browsers like IE6.
So, what happens if you take the harness off? Allow yourself to use any and all new features that you like? Live a little, go crazy, use weird bleeding edge features that only 1% of your users will be able to take advantage of?
Of course, with unlimited resources and the ability to talk to a server, you can do all manner of things—load megabytes of code and libraries and videos, and so on—but challenges aren't very interesting without constraints. The major constraint for this contest is: what can you do in a single, self-contained, 4k data: URI? Self-contained means it must not refer to any external resources, connect to any servers using WebSockets or XHR, or anything of the sort. If you want to embed resources like PNGs or MP3s, feel free to include data URIs within your data URI, or come up with some other clever way of embedding sub-resources. 4k means 4096 bytes, properly URI-encoded, ASCII text (you may use a base64 encoded data URI if you choose, to avoid URI encoding, but usually URI encoded text will be smaller than base64 for plain text).
To provide inspiration, the theme of the contest is StackOverflow memes. Create a unicorn-jousting game, a Jon Skeet fact generator, a freehand-circle based drawing program, or anything to do with one of the popular StackOverflow & meta.so memes.
I would encourage entries that are interactive in some way; not just a simple animation or static image, they should respond to user input, whether through events, CSS hover, scrolling, browser window resizing, or any other way you can think of. This is not a hard requirement, though; great demos that are not interactive will be considered, though interactivity would be preferred.
Your entry must run in at least one public release of at least one of the 5 major browsers (IE, Firefox, Chrome, Safari, Opera). Only mainline releases (not builds from branches or builds that require patches), with no special configuration settings, plugins, or anything else that does not come with the stock browser are allowed. Nightly builds, betas, and release candidates are fine. Please specify in your entry which browsers you've tested your entry with. There are no limitations on what technologies you may use within those constraints; you may do a pure SVG animation, a pure CSS animation, something in JavaScript using WebGL, or heck, even something that uses XML and XSLT if that strikes your fancy. If you can cram it into a valid data URI, with no external dependencies, and get a browser to run it, it's fair game.
To add to the competition here, on Monday, March 21, I will open a bounty on this question. How can I afford a bounty when I have only 101 rep? Well, all rep I gain from upvotes to this question between now and Monday will go into the bounty (up to the limit of 500 allowed for a single bounty; it would be pretty hard for me to hit that limit, though, given the rep cap). Entries will be accepted for 6 days after that; all entries must be in at least 24 hours before the bounty expires, to give me time to check them all out and evaluate them. At that point, I will accept the highest voted answer, and give the bounty to my favorite answer (which may or may not be the same as the highest voted). My criteria for awarding the bounty will include beauty, fun, clever technique, interesting use of new features, interactivity, and size. People should vote based on any criteria they want, as long as the entries meet the rules.
Here are some sources of inspiration, to get you started:

Chrome Experiments, a collection of demonstrations of the modern web platform
Mozilla Hacks, a blog about the modern web platform with many demos of new features in Firefox 4
JS1k, a contest for 1k JavaScript demos
10k Apart, a webapp in 10k contest
gl64k, a demo contest currently running for 64k WebGL demos
Shader Toy, a set of demos of what you can do with WebGL shaders

Format for entries:

Name of entry
data:text/html,Your%20data%20URI
Works in Firefox 4 RC, Chrome 10, and Opera 11
Description of your entry; what it does, why it's neat, what clever techniques you used.

Any credits for inspirations, any code you might have borrowed from, etc.

(StackExchange appears not to accept data URIs in links, so you'll need to embed it directly in a
 tag)

@Joey I linked to a thread on SO memes for reference, for anyone not familiar. Here are some of the more popular ones to get you started: unicorns, waffles, freehand circles (that is, circles or other diagrams drawn freehand in MS Paint or similar applications, commonly used for highlighting some sort of user interface bug), Jon Skeet and Chuck Norris-style "facts" about him.

By the way, entries do not need to not need to be about StackOverflow memes in general; just pick one meme, like unicorns. In fact, I was thinking of making the theme be unicorns, but decided to open it up a little by allowing any StackOverflow meme. And heck, if you have a cool demo that doesn't fit the theme, submit it anyhow. The theme is there mostly to provide inspiration, not to restrict what you do.

I have got an idea, but I think it will take 6 to 8 weeks to implement, could you extend the deadline a bit?

@eBusiness Ha ha! No, unlike Stack Overflow, there are actually deadlines here.

more entries please?

@thephpdeveloper Sadly, despite my attempts to promote this question, and the number of upvotes and views it's gotten, no one else seems to have entered. I'll wait a few more hours for last minute entries before accepting and awarding the bounty, but I don't have much more time left on the bounty so will need to award it soon. I'm guessing that most people on this site prefer smaller, more well-defined problems, not more open-ended, creative problems like this one.

SO meme: Everything is a meme

Everything is a meme. enough said.

Conway's Game of Life, HTML5+CSS3+JS,
3,543 3,561 3,555 bytes
data:text/html,<!DOCTYPE%20html>%0A<title>Conway's%20Game%20of%20Life%20by%20Sam-Mauris%20Yong</title>
Conway's%20Game%20of%20Life
<canvas%20id="c"%20width="800"%20height="600"></canvas>

<input%20type="button"%20value="Start"%20id="ctrlStart"><input%20type="button"%20value="Stop"%20id="ctrlStop"><input%20type="button"%20value="Next"%20id="ctrlNext">

App%20requires%20awesome%20browsers%20supporting%20HTML5.
Written%20by%20@thephpdeveloper%20aka%20Sam-Mauris%20Yong.

This is Conway's Game of Life written myself for HTML5 with canvas and CSS3. I wrote it for fun during the period of 10K Apart competition but I did not submit this for the competition.
Base64 encoded version spans over 4.61KB of data, whereas the original version is ~3543 bytes.
To compress the size: Javascript code minified by YUI online compressor, then by Dean Edwards' packer. CSS Code minified by YUI online compressor. Uses jQuery library from Google API Library. Valid HTML5 and CSS3 (experimental version of the w3 validator).
To play:

Black box represents a live cell, white represents dead cell.
Click on a box to mark a live cell, click again to mark it dead.
Press <Start> to run the simulation, <Stop> to pause, and <Next> to show the next step
Runs awesome on Internet Explorer 9, Firefox 4 (and Firefox 3 as well), Safari 5, and Google Chrome.

The human-readable (robots shall die) version:
<!DOCTYPE html>

        <title>Conway's Game of Life by Sam-Mauris Yong</title>

Conway's Game of Life

    <canvas id="c" width="800" height="600"></canvas>

        <input type="button" value="Start" id="ctrlStart">
        <input type="button" value="Stop" id="ctrlStop">
        <input type="button" value="Next" id="ctrlNext">

        App requires awesome browsers supporting HTML5.

        Written by @thephpdeveloper aka Sam-Mauris Yong.

A class in history:

Modified to remove dependency from jQuery as well as URI-encoding all spaces. Improved code in many ways (that I can't remember of).
Fixed bug in calculation of alive neighbours and refactored some code to reduce size.

This is very cool, but isn't the jQuery library an external dependency?

@Gareth ahh just saw it. dang.

Hosted: http://ebusiness.hopto.org/gol.htm

You don't require jQuery for much in here; you could probably replace it with raw DOM access without expanding your code too much, possibly at the expense of IE compat (but canvas isn't compatible with older IE either, so you wouldn't be losing much). If that expands it so you need to cut it down a little more to fit, you have some descriptive text you could remove, as well as some /> sequences that you can replace with > since you're not writing XHTML. Also, remember to properly URI-encode your result; while browsers might accept spaces in URIs, they aren't technically valid.

A few more things you could use to save space, if you wind up needing some. There's no actual need for , , and  tags (nor their closing tags). They're implicit in HTML, and will be added in the appropriate places by the browser.

updated the code base as per recommendations by @Gareth and @Brian. thanks @eBusiness for hosting it; it can also be viewed by saving the source code into a HTML file. You probably saved others some time :)

I hosted the new version, but it seems broken, the readable version at least.

@eBusiness thanks for letting me know. It was a variable name problem. Fixed it. Thanks!

By the way, if you want to shorten the code. It's often easier to make an array a little bigger than it's data than to check that you don't read out of bounds every time you read from it. And you could count a 3x3 square instead of a ring around a field, all you need to do is adjust the algorithm a bit to compensate.

sorry for bringing up a long dead post, but I think the stop button doesn't work.  :S

Sorry to dig up an old thread, but I saw this challenge on the side bar and I just couldn't resist. I don't mind that the challenge is over really, it was just fun coming up with something.
Maybe we could have another round?
Anyway, my submission:
Edit
Sorry to dig this up again, but it was bothering me for ages that I couldn't get this under 1KB. Now I've done it!
Interactive, Shaded Cube:
960 987 1082 1156 1182 1667 1587 bytes!, HTML+CSS3+JS
data:text/html,

Move your mouse.
Works in Chrome (18.something, but should work on most recent ones).
I golfed this pretty well, I saved a few characters using a trick I thought was pretty cool:
Say you have the following:
function g(x){alert("hello "+x+"!")}
g("dave");g("martin");g("alice");g("rose");g("bob");g("helen");g("jo");

characters can be saved by returning the function within itself and doing the following:
function g(x){alert("hello "+x+"!");return g}
g("dave")("martin")("alice")("rose")("bob")("helen")("jo");

Savings depends on how many function calls you have. This is probably better for obfuscation rather than golfing though.
I also saved a characters by replacing 1000 with 1e4, giving the Math class, and some of its functions, aliases. Using variables for repeated strings (quite hard to find some of these saves). Also, I had the word style in my code a few times; some of them were strings and others were identifiers like element.style.whatever. Assigning the string to a variable (D='style) allowed me to replace the strings with D and to replace the identifiers like so element[D].whatever.
Latest Edit: sorry to bring up an old comp', but some ideas how to shorten this just came to me!

Nice, thanks for creating an entry! This is pretty cool. I like your golfing techniques, too.

Nice, but you have plenty of space left, you should add more to it :) How about a Rubik simulator?

onmousemove could be modified: onmousemove=function(e){U=K-e.pageX;J=e.pageY-K};. This way cube will roll towards the mouse pointer (more intuitive).

If you are happy with ECMAScript 6 (it only works in Firefox (SpiderMonkey), as far as I know), then function g(x){alert("hello "+x+"!");return g} g("dave")("martin")("alice")("rose")("bob")("helen")("jo"); can become g=x=>alert("hello "+x+"!"),g;g("dave")("martin")("alice")("rose")("bob")("helen")("jo");

JavaScript 489 chars
This plays Guess a Number game.
data:text/html,<!DOCTYPE%20html>
Guess the number between 0 and 100

good luck
<form><input id="i" type="text"></input></form>
<button onclick="h()">Try</button>

I worked it out with this code:
<!DOCTYPE html>


text:
The Time Traveler
The shortest code to generate the correct times on the clocks wins.
You are a seasoned time traveler and have been known to stop at many planets during your journies.  Each planet rotates at a different rate and because of this, the length of a day is different than our usual 24-hour day.  As a result, the planets use clocks with different numbers of hours.  The hours on a clock with x hours are arranged similar to ours (1, 2, 3, ... , x) with the number rotating clockwise and x being at the top.
Additionally, each planet has a different amount of minutes in an hour, and a different number of seconds in a minute.  You will be given a starting time and a number of elapsed seconds from which you must determine the ending time.
Input can be taken directly from a file passed as an argument, or as standard input.  The first line of input will be the number of clocks you need to process.  After that, each clock has three lines of input that contains integers in the following format:
x y z
h m s
t

The meaning of each letter is below.

x = The number of hours in a day (2 <= x <= 99)
  y = The number of minutes in an hour (2 <= y <= 100)
  z = The number of seconds in a minute (2 <= z <= 100)
  h = The hour of the starting time (1 <= h <= x)
  m = The minute of the starting time (0 <= m < y)
  s = The second of the starting time (0 <= s < z)
  t = The number of seconds that have elapsed

The output must be the ending time for each clock after t seconds have passed since the starting time.  Your output must be formatted as standard clock time (HH:MM:SS).  Numbers should be padded, when necessary, to ensure that all numbers are two-digits.
Test Cases

Input
2
5 20 10
1 10 5
2633
6 25 5
6 0 3
290

Output
04:13:08
02:08:03

Input
1
14 17 11
12 16 10
1530

Output
07:03:00

Input
2
8 40 25
3 1 15
10620
14 15 20
1 14 0
-580

Output
05:26:10
14:00:00

I wonder if all the planets are inhabited by Englishmen?

@eBusiness Better give them a nice cup of not entirely unlike tea.

I think I don't understand the examples/the input format. x is the number of hours in a day - hours in that planets time, or human/earth hours? And h, the starting time is the time in that planets time, or again, human/earth time? Because: If in input 1, example 2, the planet only has 6 hours - how should the starting time be 6? That would be an invalid time.

If I understand correctly, Hours go from 1 to n. Minutes and seconds go from 0 to n-1. But is midnight n:00:00 or 1:00:00. That is where I get confused.

@CMP: As the last test case shows, the time for midnight is n:00:00.

I can see that, but I still don't agree with it. It seems like using 0005 hours being called 'twelve o' five' is an absolutely horrible way to tell time, and is more of a cultural anomaly than anything else. I would think a time traveler would be particularly interested in precise time and would use the unambiguous for '00:05' like the military does.

GolfScript - 50 chars
~](;7/{{~+.4$/\4$%])\}3*3<)@\or\+{100+`(;}%':'*n}%

The values (H/M/S) are collected by moving them to the front of the stack (])\). The hour 'underflow' at 0 is handled with or. Zero padding is handled with 100+`(;, although I suppose 0`\+-2> is the same length.

Ooooh, the 100 thing makes me mad. I wish I'd thought of it. (It would only save me 3 characters, but would have saved me much more brain time.)

Python, 142 characters
R=raw_input
for i in' '*input():x,y,z,h,m,s=map(int,(R()+i+R()).split());t=input()+h*y*z+m*z+s;print'%02d:%02d:%02d'%((t/y/z-1)%x+1,t/z%y,t%z)

If I'm not mistaken, since you use for i in ' '*input() you could actually use i instead of ' ' in R()+' '+R(), saving two characters.

You can replace the second line by this exec"x,y,z,h,m,s=map(int,(R()+' '+R()).split());t=input()+h*y*z+m*z+s;print'%02d:%02d:%02d'%((t/y/z-1)%x+1,t/z%y,t%z);"*input()

t/y/z%x or x is a character shorter.

GolfScript 62 60 characters
Edit: I managed to get the array formerly stored in a to reside on the stack, it takes a little extra switching that way though so no major improvement.
~](\7/\{(~+[]\{.5$/@@5$%\+@@+}3*;\;(@or\+{'0'\+-2>}%':'*n@}*

62 version:
~](\7/\{[]:a;(~{+.4$/\4$%a+:a;}3*;;;a(@or\+{'0'\+-2>}%':'*n@}*
1______a2____3_b4_5___6__7____8__9__10_____11_________12____13

I'm sure it can be done a lot better, I just couldn't think of anything better.
1: Make an array of all input, pick off the first element, group the rest into blocks of 7.
a/13: Consume the first number from the input to run the loop that number of times.
2: Store an empty array in a.
3: Pick a block of 7 and expand it to 7 individual numbers.
b/8: Run a loop 3 times, once for each of seconds, minutes and hours.
4: Add the last two numbers together, for the first iteration that is seconds and time to shift, for the following it is minutes and hour with the overflow from the previous cycle. Make a second copy of the result.
5: Divide the copy by it's limit to produce the overflow and shift the result back one space.
6: Calculate the modulo of the previous division to produce a part of the result.
7: Add this part to the a array.
9: Remove the hour overflow and the second and minute limits from the stack.
10: Take the hour part of a, if it's zero replace it with the hour limit, put it back in the array.
11: For each element in a, place '0' in front, thus converting to string, and throw away everything but the last 2 characters.
12: Collapse the array into a single string delimited by ':', place a newline and shift the array containing the remaining jobs to the front of the stack, thus preparing for the next iteration.

And what is 13? Good explanation! +1

@FUZxxl: 13 and 8 are end markers of blocks a and b.

J (172/35) 137 99 107
Now passes all given test cases.
4(1!:2)~LF,~"1([,':',])/"2,"2":"0(10 10#:1 0 0+{.#:{.&{:+{.#.1 0 0-~1&{)"2&(,&}.$~,&3 3&{.&{.)".;._2(1!:1)3

172 is the whole thing; 35 is the number of characters I would give if I was really snooty and refused to do the IO as indicated. (I still modified it a little bit; clocks is a function taking a filename meant to be used interactively within J.)
I sure hope this is a lot easier in J than I make it look.
Edit: Figured out how to do better input parsing in J, eliminated charsub, switched to command line invocation & output.
Edit 2: Changed input of central function to 3x3 matrix, eliminated many pesky parentheses, eliminated names
Edit 3: 0-o'clock handled.
Explanation:
My J still isn't great, and IO is a pain as always. So bits of this are loony.

The verb 1 0 0+{.#:{.&{:+{.#.1 0 0-~1&{ takes a three by three matrix (consisting of the input lines, the last two elements are garbage)
The h/m/s is gotten with {. (head), the actual time with 1&{ (second element), and the second count with {.&{: (head of tail).
The verb uses #. to transform the clock time to seconds. (See documenation.)
It adds the second count and then uses #: to get the 3 element answer.
The 0 o'clock case is handled by subtracting 1 from the hour before the base change and adding 1 back after. (the two bits with 1 0 0)
The rest is input and output, which is really grubby (as always).
".;._2(1!:1)3 gets a 3 'column' matrix of the input with 0s in unfilled positions.
,&}.$~,&3 3&{.&{. cuts the first row off the input and shapes the remaining rows into Nx3x3.
The "2 modifies the central verb to take the 3x3 cases.
10 10&#: gives 2 decimal digits for each number giving an Nx3x2 matrix. (Getting 0s for padding was a pain.)
,"2":"0 converts the digits to ASCII (Nx3x2x1) and ravels the last column, giving Nx3x2 again as ASCII.
LF,~"1([,':',])/"2 inserts : between each element and appends them (Nx7) and adds a line feed per for (Nx8).
4(1!:2)~ prints each row.

Haskell, 159 characters
v(_:x:y:z:h:m:s:t:r)=(w%x+1)&":"$z%y&":"$1%z&"\n"$v$t:r where w=y*z;(%)=mod.div(t+h*w-w+m*z+s)
v _=""
d&c=tail.(shows(d+100)c++)
main=interact$v.map read.words

Edit: (207 -> 200) sometimes divMod isn't worth it!
Edit: (200 -> 178) succumbed to not using the elegant foldr approach (which works for time systems with any number of components!)
Edit: (178 -> 164) inlined f
Edit: (164 -> 158) removed unnecessary parentheses
Edit: (158 -> 160) fixed a bit introduced three edits ago: hours are now correct again
Edit: (160 -> 159) dropped a call to tail

The hour is offset by one in all outputs.

@Joey: Good catch! Fixed.

Ruby, 128 chars
Shamelessly copies from the python one:
d=$<.read.split.map(&:to_i);d[0].times{|o|x,y,z,h,m,s,t=d[o*7+1,7];t+=z*(y*h+m)+s;puts ["%02d"]*3*':'%[(t/y/z-1)%x+1,t/z%y,t%z]}

Haskell - 219 necessary characters
import Text.Printf
(#)=div
(%)=mod
n?d=(n-1)%d+1
e a n=mapM(\_->a)[1..n]
main=readLn>>=(e$do{
 a<-e getLine 3;
 let[x,y,z,h,m,s,t]=map read.words=<<a;
    w=y*z;e=h*w+m*z+s+t::Int
  in printf"%02d:%02d:%02d\n"(e#w?x)(e#z%y)(e%z)})

Bash - 189 characters:
read n
for((i=0;i<n;i++));do
read x y z
read h m s
read t
R=$(((s+m*z+h*y*z+t)%(x*y*z)))
H=$((R/y/z))
R=$((R-H*y*z))
M=$((R/z))
printf"%02d:%02d:%02d\n"$((((H-1)%x+x)%x+1))$M$((R-M*z))
done

As I recall the second mod is there for negative elapsed seconds.

That printf line doesn't work. Spaces are required between printf and its arguments and between those arguments...

Java, 486 371 characters
Ungolfed version: http://pastebin.com/6LiTdGyi
This gives the same output as in the provided examples.
But I disagree on that behavior: a clock does not have as many numbers as there are hours in a day: it has half of them.
Meaning that if you add 3600 seconds to 12:50:12, it should print 01:50:12, not 13:50:12 (in our standard 24/60/60 system).
I handled that in my code but commented it out in my solution for it to match the examples.
Of course if you consider this, then the input times could be considered ambiguous unless you add some AM/PM marker.
But in any case, the puzzle has an inconsistency: if 00 hours should be replaced by x, then hours > (x/2) should be replaced by hours - (x/2).
Edit:
Golfed version:
import java.io.File;import java.util.Scanner;public class U{static int i(Scanner s){return
s.nextInt();}public static void main(String[]g)throws Exception{Scanner s=new Scanner(new File(g[0
]));int n=i(s);while(0!=n--){int J=i(s),K=i(s),L=i(s),P=(i(s)*K*L+i(s)*L+i(s)+i(s))%(J*K*L);System.
out.println(String.format("%02d:%02d:%02d",(0==P/L/K%J)?J:P/L/K%J,P/L%K,P%L));}}}

Hi there, a [code-golf] question requires the shortest answer in the total number of characters. This means a golfed entry should, at least: 1. not use package declarations; 2. not use final; 3. use single-character variable names and class names; 4. generally use the cleverest ways to make the shortest code possible.

It doesn't matter if your code is unreadable or not; therefore, your "unreadable" version is not useful for a code golf contest if it's not otherwise short. To be honest, Java is a poor language for entering a golf contest with, because compared to most languages, Java is so verbose. :-(

In the near future, I'll be doing a cleanup exercise where non-golfed entries will be removed from [code-golf] questions. So, if you can make a golfed version (see my first comment), please do; otherwise, your answer will be removed at the next cleanup.

Hi. Sorry for it all. I got confused... I ended up understanding what golfing meant. I kept the ungolfed version as a link only. I hope that is fine especially because of my doubts regarding the input and expected result. I put then a better golfed version. Right Java ain't the best but I think I did well enough for this golfed version to be kept here. Sorry again.

@tisek: Thanks for your new version. Here's a suggestion for shortening the code even further: instead of int[]c={i(s),i(s),i(s),i(s),i(s),i(s),i(s)}, you may want to use int a=i(s),b=i(s),c=i(s),d=i(s),e=i(s),f=i(s),g=i(s). Yes, you add 11 characters here, but you save three characters each time you use c[x], which means after 4 such instances, it's paid for itself. I counted 13 such instances, which means you save 28 characters overall!

@Chris Jester-Young Thanks for the tips. Actually, there was still a lot of room for shortening with inlining variables used only once, replacing the for with the while and so on...

Use stdin instead of a file (-25). You can shorten the import to java.util.* (-6). You can use an enum (enum U{U;static int i(..){..}{/*maincode*/}}) instead of a normal class (-56). Change the loop condition to s==s (exit on error) and remove int n= (-8). You don't need to reduce the size of P (%(J*K*L)) -- (-10). Change the hour underflow condition to 1> and remove the parenthesis (-3). New total is 261.

@Nabb: thanks, I will do that. It's crazy how something as verbose as Java has room for shortening :P

PHP (241 chars)
Takes input from a file passed as an argument.
foreach(array_chunk(array_slice(file($argv[1]),1),3)as$v){list($x,$y,$z)=split(" ",$v[0]);list($h,$m,$s)=split(" ",$v[1]);$e=($v[2]+$s+$z*($m+$h*$y))%($x*$y*$z);$s=$e%$z;$e/=$z;$m=$e%$y;$h=($e/$y)%$x;printf("%02d:%02d:%02d\n",$h?:$x,$m,$s);}

And ungolfed:
$input = array_chunk(array_slice(file($argv[1]),1),3);
foreach($input as $v){
    list($x,$y,$z)=split(" ",$v[0]);
    list($h,$m,$s)=split(" ",$v[1]);
    $t = $v[2];
    $seconds_in_day = $x * $y * $z;
    $total_elapsed = $t + $s + $m*$z + $h*$y*$z;
    $elapsed = $total_elapsed % $seconds_in_day;

    $sec = $elapsed % $z;
    $elapsed /= $z;

    $min = $elapsed % $y;
    $elapsed /= $y;

    $hours = $elapsed % $x;
    if ($hours == 0) $hours = $x;

    printf("%02d:%02d:%02d\n",$hours,$min,$sec);
}

And just to note, without sigils (the dollar sign), this comes out to 205 characters.

PHP, 229 228 characters
<?$v=file($argv[1]);while(++$i<$v[0]*3){list($x,$y,$z)=split(" ",$v[$i++]);list($h,$m,$s)=split(" ",$v[$i++]);$s=($e=($v[$i]+$s+$m*$z+$h*$y*$z)%($x*$y*$z))%$z;$m=($e/=$z)%$y;printf("%02d:%02d:%02d\n",($e/$y)%$x?$e%$x:$x,$m,$s);}

File must be passed into the script as an argument
Ungolfed:
<?php

$v = file($argv[1]); // Automatically break the file into an array by line

while(++$i < $v[0]*3){ // Loop for every three lines
  list($x, $y, $z) = explode(" ", $v[$i++]); // Break apart the first line by space
  list($h, $m, $s) = explode(" ", $v[$i++]); // Break apart the second line

  /*
    Add the starting time to the total number of seconds that have passed
    Divide by total amount of seconds in a day
  */

  $time = ($v[$i] + $s + $m * $z + $h * $y * $z) % ($x * $y * $z);

  $seconds = $time % $z;  // Get the number of seconds
  $minutes = ($time /= $z) % $y; // Remove the end amount of seconds, then get the minutes

  /*
    Remove the end amount of hours
    Determine how many hours there would be
    If the number is zero, then output the max hours
    If the number is not zero, output the amount of hours left
  */

  $hours = ($time / $y) % $x? $e % $x : $x;

  // Display the time in the correct format
  printf("%02d:%02d:%02d\n", $hours, $minutes, $seconds);
}

Changelog:
229 -> 228: No need to set time remaining while performing division on the hours

Bash, 139 characters
read n
while((n--));do
read x y z;read h m s;read t
((t+=z*(y*h+m)+s,a=(t/y/z-1)%x+1,b=t/z%y,c=t%z))
printf %02d:%02d:%02d\\n $a $b $c
done

Scala 184 chars:
object C extends App{val r=new java.util.Scanner(System.in)
def n=r.nextInt
for(j<-1 to n;h=n;m=n;s=n;x=n;y=n;z=n;t=n;d=(x*m+y)*s+z+t){printf("%02d:%02d:%02d\n",d/(m*s)%h,d/s%m,d%s)}
}

In conflict to the rules, I claim, that for
14 15 20
1 14 0
-580

The output shouldn't be
14:00:00

but
00:00:00

and that's what my code produces. Please show me a clock which displays 24:00:00 on earth instead of 00:00:00 - maybe 24:59:59. Or do you expect the sequence:
23:59:59
24:00:00
00:00:01

instead of
23:59:59
00:00:00
00:00:01

On Earth, you won't see 24:00:01, but you do occasionally see 'day N at 24:00:00' used as a synonym for 'day N+1 at 00:00:00'.  It's the same time but a different focus - 'midnight tonight' vs 'midnight tomorrow morning'.

Python 2, 137 bytes
lambda T:["%02d:%02d:%02d"%((s/z/y%x,x)[s%x<1],s/z%y,s%z)for x,y,z,h,m,s,t in[T[i:i+7]for i in range(1,len(T),7)]for s in[s+m*z+h*y*z+t]]

Try it online!
Only slightly shorter than the other Python answer, but takes a different route to get there.
Ungolfed Explanation:
def f(T):
    # ignore first list element, split list into even chunks of length 7
    for i in range(1, len(T), 7):
        # get variables for sublist
        for x, y, z, h, m, s, t in [T[i:i + 7]]:
            # get total time in seconds, inside a list so that we can use list comprehension
            for s in [s + m*z + h*y*z + t]:
                # split total time into parts
                # seconds: convert seconds to minute, take remainder
                sec = s % z
                # minutes: convert seconds to minutes (discard remainder), convert minutes to hours, take remainder
                min = s / z % y
                # hours: convert seconds to minutes (discard remainder),
                #        convert minutes to hours (discard remainder),
                #        convert hours to days, take remainder
                # if seconds are evenly divisible by total hours, use number of hours in day instead ("midnight")
                hr = (s / z / y % x, x)[s % x < 1]

                print "%02d:%02d:%02d"%(hr, min, sec)

Haskell (815 624 chars non-golfed, blank lines excluded)
Mine prints 00:00:00 instead of 12:00:00 or similar for "midnight"-like times. Edit: changed that.
main = readFile "in.txt" >> mapM_ print . times . map (map read . words) . tail . lines

times [] = []
times ([x,y,z]:[h,m,s]:[t]:xs) = Time x y z h m s +++ t : times xs

data Time = Time {x,y,z,h,m,s :: Int}
hr t | h t == 0 = x t | otherwise = h t

instance Show Time where show t = pad2 (hr t) ++ ':':pad2 (m t) ++ ':':pad2 (s t)

pad2 x | x < 10 = '0':show x | otherwise = show x

t +++ ss | ss < 0  = t +++ (ss + x'*y'*z') | otherwise = Time x' y' z' h' m' s'
  where (x',y',z') = (x t, y t, z t)
        (ms, s') = (s t + ss) `quotRem` z'
        (hs, m') = (m t + ms) `quotRem` y'
        (_,  h') = (h t + hs) `quotRem` x'

Could've abstracted a few things more, but w/e. It completely ignores the first line of the input file, and generally screams at you for improperly-formatted files.

Note it would be easy to manipulate this solution to allow for more than two digits for hours, minutes, and seconds.

"The hours on a clock with x hours are arranged similar to ours (1, 2, 3, ... , x)", so 00:00:00 isn't valid.  Shouldn't be difficult to adjust for that though.

@Bass5098 fixed, and shortened a bit. I still don't have the heart to gut it out into an unreadable form, though.

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


text:
Finding maximum paths
Given a square of positive, natural numbers write a program find a horizontal and a vertical path with the sum of numbers along them being maximal. A horizontal path goes from the first column to the last and has to increase its column position by one in each step. A vertical path goes from the first row to the last and has to increase its row position by one in each step. Furthermore the row position in a horizontal path may stay the same or change by one in either direction, likewise for vertical paths.
To illustrate, the following could be a valid path:

The following path would be invalid, since it steps backwards (and remains on the same row in some places):

The following path would be equally invalid, since it changes the row position by more than one in a single step:

Note: The solution should run in an acceptable amount of time.
Input
n lines of input with n space-separated positive integers each are given on standard input. 2 ≤ n ≤ 40. Every line is terminated by a line break. The numbers are small enough that the maximum sum fits in a 32-bit signed integer.
Output
The maximum sums of the horizontal and vertical paths (in that order) separated by a single space.
Sample input 1
1 2
1 2

Sample output 1
3 4

Sample input 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 4 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 4 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 5 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 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 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 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 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 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 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 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 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 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 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Sample output 2
37 35

Sample input 3
683 671 420 311 800 936
815 816 123 142 19 831
715 588 622 491 95 166
885 126 262 900 393 898
701 618 956 865 199 537
226 116 313 822 661 214

Sample output 3
4650 4799

For your convenience we have prepared a few test cases in bash (thanks to Ventero) and PowerShell which you can run your program through. Invocation is: <test> <command line>, so something like ./test python paths.py or ./test.ps1 paths.exe. Have fun :-)

@Joey: Slightly altered task from one we used last year in our contest :)

+10 for the bash test script! I wish all code golf came with such.

@MtnViewMark: We try :-) Personally I hate tasks that require too much clarification after being posted and I usually write my own test scripts anyway since I need to know when an attempt to golf further introduces a regression. Also I have observed that some people tend to post plainly wrong answers. Test cases help getting everyone on the same line. Having a facility that works for every task instead of just one-off hackjobs for each task would clearly be better, but we're not quite there yet ;-)

GolfScript - 49 Nabb enhanced characters
51 characters
50 strictly and utterly necessary characters + 3 slackers that only did the job of 1
56 mostly redundant characters
n%{~]}%.zip{{0@+\{\.1>\3<$-1=@+}%\;}*$-1=\}2*' '@

51 solution:
n%{~]}%.zip{(\{0@+\{\.1>\3<$-1=@+}%\}%;$-1=\}2*' '@

53 solution:
n/{~]}%);.zip{(\{0@+\{\.1>\3<$-1=@+}%\}%;$-1=\}2*' '@
             a8_b9___c10___11______12 13      14_

The method works on two lines at a time, one containing the maximum sums reached at each point, and one containing the next line.
a/14: Repeat twice, once for each result.
8: Take the first line from the input and switch it behind the input array, this in now the first set of maximum sums.
b/13: Iterate over each remaining line in the array.
9: Put 0 at the beginning of the maximum sums.
c/12: Iterate over each element of the line.
10: Make a copy of the maximum sums with the first element removed.
11: Take the first 3 elements of the maximum sums, sort them and add the largest to the current element of the line.
56 solution:
n/{~]}%);.zip{1,99*\{{\.1>\3<$-1=@+}%0\+\}%;$-1=\}2*' '@
1________2___ 3____ 4______________________5_____ 6_7___

1: From input to array of arrays in 9 characters, actually it could have been done with just 1, but I broke that key so this will have to do.
2: 4 characters just to make a transposed copy.
3: Array of 99 0s in 5 characters, it could probably be done in a way smarter fashion, but I smoke too much weed to figure how.
4: Overly complicated double loop that iterate over every single element of the input and does some fuzzy logic or something like that to produce the result. Nabb will probably make something equivalent in around 3½ characters.
5: By now the result is there, inside an array that is, this silly piece of code is just there to get it out (and junk a piece of leftovers (and switch the result into place)).
6: This is a command so simple that its character count would probably be negative in an optimal solution.
7: At this point the program is really done, but due to sloppiness in the preceding code the output is in the wrong order and lacks a space, so here goes a few more bits down the drain.

Ahh, I just accidently assumed the input not to end with a newline. I'm surprised that it actually worked partially, that kind of stuff usually mess up a GolfScript program completely.

Looks fine, although you should be using {}* instead of (\{}%.

J, 91 95
a=:".;._2(1!:1)3
c=:4 :'>./x+"1|:y,.(1|.!.0 y),._1|.!.0 y'
p=:[:>./c/
(":(p|:a),p a)1!:2(4)

I decline to do IO, lowering my score dramatically. Passes all tests in the test harness (though it only works if the input ends with a line ending, as in the test harness).
I removed the handling for Windows line endings, since Chris suggested that it wasn't necessary. The multi-platform version would have a=:".;._2 toJ(1!:1)3 as the first line.
Explanation:

f gives the solution pair by calling p normally and with input transposed (|:).
p takes the maximum (>./) of the row-totals from applying c between each row (c/)
c takes two rows (x and y). It adds x to each of y, y shifted up 1 cell (1|.!.0 y), and y shifted down 1 cell (_1|.!.0 y). Then it takes the maximums of the three alternatives for each row. (>./). The rest is rank [sic] - I'm not sure if I'm doing it right.

Exactly, lowering your score. -1

@eBusiness: Are you sure downvoting is the right response to an incomplete solution?

@Joey: Not upvoting is the other option. I was too tired to do IO at the time, but my solution is so different from the other J solution that I really wanted to post it anyhow. If there was an explicit way to mark the answer as "non-participating", or something like that, I would have.

@Joey: Another reason is that down-votes are unlikely to be reversed even if the solution is fixed; the original user has to come back and change their vote. (Deleted, realized that short-circuited the discussion, and undeleted. I guess I'll shoot for the "Disciplined" badge instead.)

@Jesse Millikan: We do that. No guarantees, but if you fix the issue within reasonable time most downvoters should revoke their votes.

@Jesse: I don't think "non-participating" answers should be encouraged, as that often lowers the S/N ratio for challenge posts. CW is indeed one possibility, but I'll be starting a discussion about whether non-golf answers to [code-golf] threads should be permitted at all---and if it's agreed that they're bad to have, I'll start actively deleting such answers.

@Chris: Edit: Will wait until you post something on meta to comment on that. Also, note that my answer was a wrong golf answer, not a non-golf answer :)

@Chris, @Joey, @eBusiness: Fixed IO. Thanks for the... Clarification, or whatever that was. Meanwhile, can someone answer me whether we're expected to account for both Windows and Unix line endings?

Also, my most sincere apologies to anyone trying to read edit histories of my answers. I'm edit-crazy.

@Jesse: I withdrew my downvote. I think it's fair to use LF line endings, since those are usually less of a pain to handle than CRLF ones.

Since it's not specified in the question I'd say you can use the lineshifts of your choice.

That's three or four characters I can certainly live without...

Jesse: line endings of your choice (or whatever is appropriate on your platform). And the last line of input is indeed terminated by a line break (as stated in the task description under Input).

This would be easier if I could read. "I can read readin', but I can't read writin'."

Haskell: 314 necessary characters
import Data.Vector(fromList,generate,(!))
import List
l=fromList
x=maximum
g=generate
p a=show$x[m!i!0|i<-[0..h-1]]where{
w=length$head a;h=length$a;n=l$map l a;
m=g h$ \i->g w$ \j->n!i!j+x[k#(j+1)|k<-[i-1..i+1]];
i#j|i<0||i>=h||j>=w=0|1>0=m!i!j;}
q a=p a++' ':(p.transpose)a
main=interact$q.map(map read.words).lines

Note: this requires the module Data.Vector.  I'm not sure if it's included in the Haskell platform or not.
Ungolfed version:
import Data.Vector(fromList,generate,(!))
import Data.List

-- horizontal; we use transpose for the vertical case
max_path :: [[Integer]] -> Integer
max_path numbers = maximum [m ! i ! 0 | i <- [0..h-1]] where
    w = length (head numbers)
    h = length numbers
    n = fromList $ map fromList numbers
    m = generate h $ \i -> generate w $ \j ->
        n ! i ! j + maximum [f i' (j+1) | i' <- [i-1..i+1]]
    f i j | i < 0 || i >= h || j >= w = 0
    f i j = m ! i ! j

max_paths :: [[Integer]] -> String
max_paths numbers = (show . max_path) numbers ++ " " ++
                    (show . max_path . transpose) numbers

main = interact $ max_paths . map (map read . words) . lines

This solution uses laziness, in tandem with Data.Vector, for memoization.  For every point, the solution for the maximum path from it to the end is computed, then stored in the cell of Vector m and reused when needed.

I guess you can strip the curly braces after your where statement, if you collapse all the definitions into one single line.

Ruby 1.9, 155 characters
f=->t{(1...l=t.size).map{|a|l.times{|b|t[a][b]+=t[a-1][(b>0?b-1:0)..b+1].max}};t[-1].max};q=[*$<].map{|a|a.split.map &:to_i};puts [f[q.transpose],f[q]]*" ""

Straightforward solution that passes all testcases.

Haskell, 154 characters
import List
z=zipWith
f=show.maximum.foldl1(\a->z(+)$z max(tail a++[0])$z max(0:a)a)
q a=f(transpose a)++' ':f a
main=interact$q.map(map read.words).lines

Edit: (155 -> 154) inlined the function folded over

Will using zipWith3 shorten the code?

I think you could replace maximum with foldl1 max , which adds characters but allows you to factor out foldl1 and max, which should save characters.

maximum.foldl1, max, and max --vs-- f=foldl1;m=max;, f m.f, m, and m.  -- or 20 vs. 22. So, no, it doesn't save.

Right. And i just remembered the monomorphism restriction would stop writing m=max. What about zipWith3?

Python, 149
import sys
def f(g,t=[]):
 for r in g:t=[int(e)+max(t[i-1:i+2]+[0])for i,e in enumerate(r)]
 print max(t),
g=map(str.split,sys.stdin)
f(zip(*g)),f(g)

If I were to calculate only a vertical or horizontal shortest path,
it could be done in-place instead, saving about a third of the bytes.

J, 109+10= 119 chars
y=:0".(1!:1)3
N=:%:#y
y=:y$~N,N
r=:(((1&{)(+(3>./\0,0,~]))(0&{)),2&}.)^:(<:N)
(":([:>./"1([:r|:),r)y)(1!:2)4

Run with tr:
cat << EOF | tr \\n ' ' | ./maxpath.ijs

As usual in J, most of the code is for input/output. The "actual" code is 65 characters:
r=:(((1&{)(+(3>./\0,0,~]))(0&{)),2&}.)^:(<:#y)
([:>./"1([:r|:),r)y

Passes all test cases

So we need JB again with a solution that reduces the parsing to 10 characters? ;-)

@Joey I'm on holiday, I barely have internet access; not much time for golfing ;-)

Can you clue me in on how you're directly running maxpath.ijs?

@Jesse: In *nix put some #!/usr/bin/env jconsole on top of the file and set the executable flag.

Python, 204 characters
import sys
I=sys.stdin.read()
n=I.count('\n')
A=map(int,I.split())
R=range(n)
X=lambda h,a:[a[i]+max(([0]+h)[i:i+3])for i in R]
h=v=[0]*n
for i in R:h=X(h,A[i*n:i*n+n]);v=X(v,A[i::n])
print max(v),max(h)