text:
Convert integer to string preserving order
The quest is to convert an integer to a string in such a way that 1. the order is preserved 2. using the least number of characters in the string.
Let's say I have an integer X; the objective is to create a function f (and respective inverse, g, such that:
Conditions

f(X) is a utf-8 string for all integer X
g(f(X)) = X
Ordering is preserved. That is, if I have another integer Y, X > Y implies f(X) > f(Y)
The integer means it can be negative
Assume integers in [-2^63, 2^63 - 1]

Winning criterion

The answer must fulfill the conditions above
Make f(X) represent the number in the least number of UTF-8 characters.
Of answers complying with 1 and 2, smallest code wins (sum of code of f and code of g)

Example
(Python)
def f(x):
    return '%019d' % x  # log10(2^63 - 1) ~ 18.9

def g(x):
    return int(x)

Notice that it is not clear that f is optimal since it always uses the same number of characters (independent of x).
This is my first challenge here and I'm not sure if this fits this Q&A, but it seemed to me a nice and useful problem. I'm also trying to solve it.

Comments purged as they were obsolete; please notify me of any lost information.

So you want to represent any integer using the smallest chars? Would something like f=base64encode(X) , g=base64tobase10(X) be acceptable?

@user80551, can you show that that preserves ordering, (condition 3.)? (I added numbers to the conditions so we can refer to them)

@J.C.Leitão base 64 is not much different from any other base. Your question is unclear as it mentions characters without mentioning the encoding i.e. utf-8/16/whatever. Given an infinite number of unique characters, any integer can be represented using only one of those characters. VTC as unclear.

@user80551, I'm sorry, I didn't knew so well utf-8; would it make more sense if I ask for the size in memory instead of number of chars? This is the original spirit of the challenge.

@J.C.Leitão Now this is simply asking to store it as an int (C long?) so there is NOTHING to do. Storing the integers as binary is the only solution now that you ask for storing according to bytes.

Meh, I have no time for this. I thought was an interesting problem for this website, but it seems I'm not qualified enough to pose it in the correct way. Thanks @user80551 for pointing out the problems. Flagging to close.

Add an objective tag.

@J.C.Leitão I have made the question consistently about UTF-8 characters. I agree with user80551's comment on May23 at 8.22 that memory size makes this challenge too trivial. Unfortunately it's not uncommon for new users' questions to get shot down in this way. Writing a good question is difficult I encourage you to look around and answer a few questions, and when you know what we're about, post another one. Also we have these facilities to help question askers: http://meta.codegolf.stackexchange.com/q/1596/15599 and http://meta.codegolf.stackexchange.com/q/1061/15599

@steveverrill, thanks for the input and for the changes. I'm aware of how the things work here, but I didn't expecting to be so difficult to write a question xD

@J.C.Leitão   @steveverrill    Could you please elaborate what is meant by Ordering is preserved. That is, if I have another integer Y, X > Y implies f(X) > f(Y). The function f returns a string so what exactly is meant by f(X) > f(Y) ? The question is much better now so I retracted my down-vote.

@user80551. Not my question, I only took the concept and moulded it slightly into a reasonably non-trivial challenge. My interpretation is this: ASCII strings have a lexical order: 1, 10, 11, 9, 99, A, AARDVARK, ANTELOPE...ZEBRA, a, aardvark, antelope, zebra (Absence of character n in the string counts as below ASCII 0. Note that in case-sensitive ASCII, Z comes before a, so most dictionaries are case-insensitive. String representations of numbers also suffer from such a simple definition, as can be seen by my examples.)  It's the same for UTF-8 strings, but more complicated.

Perl, 4 per integer, 115 in code
sub f{pack W4,map{$_|1<<($x<0?16:17)}unpack n4,pack"q>",$x=pop}sub g{unpack"q>",pack n4,map{$_&65535}unpack W4,pop}

Caveat: This only works if Perl has 64-bit integers. This is true if perl -V:ivsize gives 8.
If perl -V:byteorder says 87654321, I believe that you may golf both "q>" into "q", for 113 characters, but I have no 64-bit SPARC to test this.
The strings returned by f and passed to g are text strings, not binary strings. A text string is a sequence of Unicode codepoints. A binary string is a sequence of bytes. The order of the strings preserves the order of the integers when one encodes each text string in UTF-8 and checks the lexical order of the UTF-8 bytes.
Facts about UTF-8

Valid codepoints for UTF-8 are from 0 to 0xd7ff, and from 0xe000 to 0x10ffff. See RFC 3629. This makes 1112064 valid codepoints. Surrogates from 0xd800 to 0xdfff are not valid in UTF-8.
Strings have the same lexical order in Unicode codepoints and in UTF-8 bytes. It is enough to put the codepoints in order, then the UTF-8 bytes are also in order.

Scheme of conversion
Because 11120643 < 264 < 11120644, there is no scheme that can save every 64-bit integer in 3 or fewer codepoints. Some schemes would use a maximum of 4 codepoints and an average of less than 4. My simple scheme uses 4 codepoints for every integer.
I unpack each 64-bit integer into four unsigned 16-bit integers. To preserve the order of negative integers before positive integers, I put negative integers in plane 1 (Supplementary Multilingual Plane), and non-negative integers in plane 2 (Supplementary Ideographic Plane).
Negative example:

-9118070288978897167
0x81761b61bc5e96f1
0x8176 0x1b61 0xbc53 0x96f1
0x18176 0x11b61 0x1bc53 0x196f1

Postive example:

6359689164524478505
0x584227999d61e029
0x5842 0x2799 0x9d61 0xe029
0x25842 0x22799 0x29d61 0x2e029

Are 0x1fffe, 0x1ffff, 0x2fffe, 0x2ffff valid in UTF-8?
My scheme uses the Unicode noncharacters 0x1fffe, 0x1ffff, 0x2fffe, 0x2ffff. Perl refuses to encode these in UTF-8.
$ perl -MEncode -e 'encode "utf-8", "\x{2fffe}", Encode::FB_CROAK'
"\x{2fffe}" does not map to utf8 at /usr/libdata/perl5/amd64-openbsd/5.16.3/Encode.pm line 160.

Unicode Corrigendum #9 clarifies that Unicode noncharacters like 0x2fffe are valid in Unicode strings. There is no requirement to reject them in UTF-8 as Perl is doing. Python, Ruby and Tcl do not reject noncharacters in UTF-8.
The workaround for Perl is to use 'utf8' and not 'utf-8' to encode strings. The 'utf8' encoder skips the checks in the strict 'utf-8' encoder.
Ungolfed version
use strict;
use warnings;

# Convert 64-bit integer to Unicode string.
sub f {
    my $x = shift;

    # Unicode plane = 0x10000 if $x < 0, 0x20000 else
    my $p = 1 << ($x < 0 ? 16 : 17);

    # 1. Pack $x as big-endian signed 64-bit integer "q>".
    # 2. Unpack four big-endian unsigned 16-bit integers "n4".
    # 3. Add Unicode plane.
    # 4. Pack four Unicode characters "W4".
    pack "W4", map({ $_ | $p } unpack("n4", pack("q>", $x)));
}

# Convert Unicode string to 64-bit integer.
sub g {
    # Unpack characters, remove plane, pack and unpack integer.
    unpack "q>", pack("n4", map({ $_ & 65535 } unpack("W4", shift)));
}

# Test program: verify that a lexical sort on UTF-8 octets preserves
# the order of these integers.
use Encode;
my @integers = (-9223372036854775808, -4611686018427387904,
                -9999, -1, 0, 5, 44, 333, 2222, 11111,
                4294967295, 9223372036854775807);
my @strings = map { f $_ } @integers;
@strings = sort { encode('utf8', $a) cmp encode('utf8', $b) } @strings;

my $want = join ',', @integers;
my $have = join ',', map({ g $_ } @strings);
if ($want eq $have) {
    printf "ok\n";
}
else {
    die "not ok: $want ne $have";
}

PowerShell, 185
$s=32767
function f($x){$a='';while($x){$r=$x%$s;$a+=[char]($r+$s)
[long]$x=[bigint]::divide($x,$s)};$a}
function g($x){$a=0;0..($x.length-1)|%{$a+=($x[$_]-$s)*[bigint]::pow($s,$_)};$a}

Ungolfed
$shift = 32767

function f($number) {
    $string = ''
    while($number) {
        $remain = $number % $shift
        $string += [char]($remain+$shift)
        [long]$number = [bigint]::divide($number, $shift)
    }
    $string
}

function g($string) {
    [long]$number = 0
    0..($string.length-1)|%{$number += ($string[$_]-$shift)*[bigint]::pow($shift, $_)}
    $number
}

At most, the output will be length 5.
> f ([long]::MaxValue)
耆耟耯耟耇
> g '耆耟耯耟耇'
9223372036854775807
> f ([long]::MinValue)
翷翟翏翟翷
> g '翷翟翏翟翷'
-9223372036854775808

Oh, so we consider one Unicode character as one character?


text:
Riffle Shuffle Golf Time
Anyone who has spent any time around a deck of playing cards will recognize the riffle shuffle. The deck is cut in half and the two stacks are riffled simultaneously into the same pile before being tidied up in a sometimes visually appealing way.
This code-golf challenge is to write a function/method/(language equivalent) that performs the riffle shuffle on an array/stack/(language equivalent) of any size in the language of your choice.
As input, your function will except an array (language equivalent), plus how many times to run the shuffle. When done, it will return the shuffled array.
Your riffle shuffle function must implement the following algorithm:

Divide the deck into two stacks
A stack must have a minimum of 40% of the total cards in the deck and a
maximum of 60%
Choose a random stack to start with
Drop 1 - 7 cards from the bottom of the starting stack to the top of the newly shuffled deck
Drop 1 - 7 cards from the bottom of the other stack to the top of the newly shuffled deck
Repeat #3 and #4 until only one stack remains
Drop the remaining cards from the remaining stack on top of the newly shuffled deck

Smallest character count will be chosen as the answer in 1 week (May 29th).
This is the sample deck of cards to use:
[
'AH', '2H', '3H', '4H', '5H', '6H', '7H', '8H', '9H', '10H', 'JH', 'QH', 'KH',
'AC', '2C', '3C', '4C', '5C', '6C', '7C', '8C', '9C', '10C', 'JC', 'QC', 'KC',
'KD', 'QD', 'JD', '10D', '9D', '8D', '7D', '6D', '5D', '4D', '3D', '2D', 'AD',
'KS', 'QS', 'JS', '10S', '9S', '8S', '7S', '6S', '5S', '4S', '3S', '2S', 'AS'
]

Your answer should contain:

Code-golfed code
What the sample deck looks like after being shuffled twice
Un-golfed code

I've removed the extraneous [popularity-contest] here as it's not part of the scoring. Also, I've removed the langauge restrictions - we usually like to let everyone play instead of discouraging some from submitting an answer in a language they prefer.

Two things: Firstly, you should explicitly specify that steps 1, 3 and 4 are subject to randomness (and possibly a uniform distribution, if you want to enforce that). Secondly, I don't think requesting the output of a random process helps much here, because it doesn't really prove the implementation is correct and will just clutter this post.

Can I expect the deck to always have an even number of cards, or not?

This challenge would be interesting if it didn't give the step-by-step algorithm the code must implement. As is, the only competition is in how well you golf the operations (and what language you use).

@Ourous even or odd number of cards

Python (131)
Waaaay too long, even for something that came to be after a "careful" reading of the rules:
Drop 1 - 7 cards from the bottom of the starting stack to the top of the newly shuffled deck

Doens't actually say this should be random, so I'll just always drop 1 card.
Divide the deck into two stacks

A stack must have a minimum of 40% of the total cards in the deck and a maximum of 60%

Sure. I'll just always do about 50%.
Anyways, the code:
def s(d):
 b=[d.pop()for _ in range(len(d)/2)];r=[];b,d=(b,d)if id(4)%2 else(d,b)
 while b and d:r+=[b.pop(),d.pop()]
 return r+b+d

Sample output:
In [17]: s(s([
    ...: 'AH', '2H', '3H', '4H', '5H', '6H', '7H', '8H', '9H', '10H', 'JH', 'QH', 'KH',
    ...: 'AC', '2C', '3C', '4C', '5C', '6C', '7C', '8C', '9C', '10C', 'JC', 'QC', 'KC',
    ...: 'KD', 'QD', 'JD', '10D', '9D', '8D', '7D', '6D', '5D', '4D', '3D', '2D', 'AD',
    ...: 'KS', 'QS', 'JS', '10S', '9S', '8S', '7S', '6S', '5S', '4S', '3S', '2S', 'AS'
    ...: ]))
Out[17]:
['AD',
 'KH',
 'AC',
 'KS',
 '2D',
 'QH',
 '2C',
 'QS',
 '3D',
 'JH',
 '3C',
 'JS',
 '4D',
 '10H',
 '4C',
 '10S',
 '5D',
 '9H',
 '5C',
 '9S',
 '6D',
 '8H',
 '6C',
 '8S',
 '7D',
 '7H',
 '7C',
 '7S',
 '8D',
 '6H',
 '8C',
 '6S',
 '9D',
 '5H',
 '9C',
 '5S',
 '10D',
 '4H',
 '10C',
 '4S',
 'JD',
 '3H',
 'JC',
 '3S',
 'QD',
 '2H',
 'QC',
 '2S',
 'KD',
 'AH',
 'KC',
 'AS']

This is actually the code as I wrote it, I didn't specifically golfed any code. If you just want an explanation, please say so.

Golfed it down to 84 chars: s=lambda d:sum(map(list,zip(*([d.pop()for _ in d[:len(d)/2]],d)[::id(4)%2*2-1])),[]). You basically want to get your two lists, zip them, then flatten them; that is what I implemented.

Golfed it down to 77 chars: s=lambda d:sum(map(list,zip(*[d[:len(d)/2],d[len(d)/2:]][::id(4)%2*2-1])),[])

Actually, we missed something: "As input, your function will except [sic] ... how many times to run the shuffle"

id(x)%2 will always be 0 because memory addresses are aligned on 4-byte boundaries.

Cobra - 307
Don't have access to a compiler atm, so this should work, but I'll be able to check later.
def f(d,n) as List<of int>
    r=Random()
    x=d.count
    for m in n
        p=q=[]
        for c in x
            if c%2>0,p.add(d.pop)
            else,q.add(d.pop)
        if r.next(0,2)>0,a,b=p,q
        else,a,b=q,p
        for c in x
            for z in r.next(0,7),if a.count>0,d.add(a.pop)
            for z in r.next(0,7),if b.count>0,d.add(b.pop)
    return d

Python 84
Golfed:
def s(d):
 e=len(d)/2;B=d[:e];C=d[e:];D=[]
 for x in range(e):D+=B[x],C[x]
 return D

Output Deck:
['AH', 'AC', 'KD', 'KS', '2H', '2C', 'QD', 'QS', '3H', '3C', 'JD', 'JS', '4H', '4C', '10D', '10S', '5H', '5C', '9D', '9S', '6H', '6C', '8D', '8S', '7H', '7C', '7D', '7S', '8H', '8C', '6D', '6S', '9H', '9C', '5D', '5S', '10H', '10C', '4D', '4S', 'JH', 'JC', '3D', '3S', 'QH', 'QC', '2D', '2S', 'KH', 'KC', 'AD', 'AS']

Un-golfed:
def Shuffle(Deck):
    Stack1 = Deck[:len(Deck)/2]            # 2nd Half of Deck
    Stack2 = Deck[len(Deck)/2:]            # 1st Half of Deck
    Output = []                            # Initialize Output List
    for index in range(len(Deck)/2):
        Output.append(Stack1[index])       # Append Output List with element from Stack1
        Output.append(Stack2[index])       # Append Output List with element from Stack2
    return Output                          # Return Output

Uses the same loopholes as @synthetica.

You missed one thing: "Choose a random stack to start with"

Actually, we missed something else: "As input, your function will except [sic] ... how many times to run the shuffle"

@Quincunx Oh, that wasn't in the list but I see it now, I'll work on this later...

Python, 69 chars (actually takes number of times to shuffle as input)
If one follows the algorithm, always picking 1 card at each step of 1-7 cards (as it wasn't explicitly said to have to be random), then with an array like:
[1, 2, 3, 4, 5, 6]

We have one of two results depending on which stack is picked first:
[1, 2, 3] [4, 5, 6] ==> [1, 4, 2, 5, 3, 6]
[4, 5, 6] [1, 2, 3] ==> [4, 1, 5, 2, 6, 3]

The following algorithm accomplishes this n times, using id(b)%9>4 as a source of binary randomness[1]:
def s(d,n):
 for i in range(n):b=d[:];F=id(b)%9>4;d[F::2]=b[26:];d[1-F::2]=b[:26]

Sample output:
>>> o = ['AH', '2H', '3H', '4H', '5H', '6H', '7H', '8H', '9H', '10H', 'JH',
 'QH', 'KH', 'AC', '2C', '3C', '4C', '5C', '6C', '7C', '8C', '9C', '10C', 'JC',
 'QC', 'KC', 'KD', 'QD', 'JD', '10D', '9D', '8D', '7D', '6D', '5D', '4D', '3D',
 '2D', 'AD', 'KS', 'QS', 'JS', '10S', '9S', '8S', '7S', '6S', '5S', '4S', '3S',
 '2S', 'AS']
>>> d = o[:]; s(d, 2); d
['KD', 'KS', 'AH', 'AC', 'QD', 'QS', '2H', '2C', 'JD', 'JS', '3H', '3C', '10D', '10S', '4H', '4C', '9D', '9S', '5H', '5C', '8D', '8S', '6H', '6C', '7D', '7S', '7H', '7C', '6D', '6S', '8H', '8C', '5D', '5S', '9H', '9C', '4D', '4S', '10H', '10C', '3D', '3S', 'JH', 'JC', '2D', '2S', 'QH', 'QC', 'AD', 'AS', 'KH', 'KC']
>>> d = o[:]; s(d, 2); d
['AC', 'AH', 'KS', 'KD', '2C', '2H', 'QS', 'QD', '3C', '3H', 'JS', 'JD', '4C', '4H', '10S', '10D', '5C', '5H', '9S', '9D', '6C', '6H', '8S', '8D', '7C', '7H', '7S', '7D', '8C', '8H', '6S', '6D', '9C', '9H', '5S', '5D', '10C', '10H', '4S', '4D', 'JC', 'JH', '3S', '3D', 'QC', 'QH', '2S', '2D', 'KC', 'KH', 'AS', 'AD']

[1] This gives about a 44.4%/55.5% skew:
>>> r = {0: 0, 1: 0}
>>> for i in range(1000000):
        r[int(id(i)%9>4)]+=1
>>> r
{0: 555517, 1: 444483}

For two extra characters we can get a much better 50.5%/49.5% result:
>>> r = {0: 0, 1: 0}
>>> for i in range(1000000):
        r[int(id(i)%99>49)]+=1
>>> r
{0: 505050, 1: 494950}

source: Stack Exchange

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

sort: votes


text:
Theatre Seating
Task
A theatre has 10 rows, labelled A to J from front to back, and 15 seats in each row,
numbered 1 to 15 from left to right.
The program uses the following rules to choose the best seats.

Rule 1: All seats in one booking must be in the same row, next to each other.
Rule 2: The seats must be as close to the front as possible, then as close to the left as possible (lowest letter, then lowest number)

Write a function which takes the number of tickets wanted as an integer input (n), and outputs the best seats available in a list of length n.
Your program should:

Output -1 if 1 > Input or Input > 15*
Output -1 if the seats aren't available*
Have a function B(n) that the user can use to input the desired number of seats.

*You can output the -1 in a list if it makes it easier
Examples
I/O
Calling B(5) on a new array should return [A1, A2, A3, A4, A5]
Calling B(2) after that should then return [A6, A7]
Calling B(10) after that should then return [B1, B2, ... B9, B10]
Calling B(-1) should always return -1
Un-golfed Solution Python
Theatre = [ [False] * 16 ] * 11

def B(n):
    if 0 <= n <= 15:
        for i in range(10):
            for j in range(15-n+1):
                try:
                    if not Theatre[i][j]:
                        if not Theatre[i][j + n]:
                            row = i
                            start = j
                            List = []
                            for q in range(n):
                                List.append(chr(row + 65) + str(start + q + 1))
                                Theatre[row][start + q] = True
                            return List
                except:
                    break
    return -1

Is "Have hardcoded a list of seats in a two dimensional array" necessary? There are numerous ways to do this without that; the requirement really restricts solutions.

You say the 2-D array must be hard-coded, but your Python example doesn't even hard-code it, it uses a comprehension to create a new list at runtime.

Can I return ['-1'] instead of -1?

You guys are right, amending now...

@Ourous Sure, that sounds reasonable :)

Why even mention "a list of seats in a two dimensional array"? That sounds like an implementation detail and if somebody creates a program that satisfies the required output without using an array, there should be no problem with that.

@GregHewgill Ammended

what if input is 0?

@edc65 I always make my nonexistent movie theater patrons sit in the best spot of the theater, on another patron's lap if need be. They never notice.

@edc65 As the rules say, output -1

OK, I'll change my answer according to this. But that's not what the rules say. "-1 if 0 > Input ..." and 0 is not > 0. I suggest changing to if "-1: if input < 1 or input > 15."

Does the returned list need to be sorted or is it okay to just have the correct seats?

@nderscore Just a list, sorting doesn't matter

JavaScript - 172
Function itself is 172:
//build persistent seats
m=[];
for(i=10;i--;){m[i]={r:String.fromCharCode(i+65),s:[]};for(j=0;j<15;j++)m[i].s.push(j+1);}

function b(z){for(i=0;i<m.length;i++)for(j=0,u=m[i].s.length;o=[],j<u;j++)if(u>=z&z>0){for(m[i].s=m[i].s.slice(z),p=m[i].s[0]||16;o[--z]=m[i].r+--p,z;);return o;}return-1;}

Input:
console.log(b(-1));
console.log(b(0));
console.log(b(4));
console.log(b(15));
console.log(b(1));
console.log(b(20));

Output:
-1
-1
[ 'A1', 'A2', 'A3', 'A4' ]
[ 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10', 'B11', 'B12', 'B13', 'B14', 'B15' ]
[ 'A5' ]
-1

Javascript (ES6) - 130 127 107 101 98
B=n=>(a=>{for(;n>0&a<9;)if((b=~~B[++a]+n)<16)for(B[a]=b;n--;)c[n]='ABCDEFGHIJ'[a]+b--})(c=[-1])||c

Demo here: http://jsfiddle.net/tBu5G/
Some ideas taken from @edc65

c[B[a]=b] instead of c[],B[a]=b is clever, but fails for n=0

@edc65 nice catch. I've now adjusted it to handle the case n=0

Awesome. That's something to remember to avoid 'return' - thanks for sharing (+1)

@edc65 thanks! I thought it was interesting. MT0's got us both beat though! :P

Haskell, 129
t=[[a:show s|s<-[1..15]]|a<-['A'..'J']]
b n=(n%).span((<n).length)
_%(h,[])=([],h)
n%(j,(r:s))=let(t,u)=splitAt n r in(t,j++u:s)

Some adjustments had to be made to make this a function in Haskell: b returns a pair: the tickets (if possible), and the new state of the theater. t is the initial theater state, with all tickets unsold. Also, returning -1 was unnatural for Haskell, so if no tickets can be issued for a request, the empty list is returned for the tickets.
λ: let (k1,t1) = b 5 t
λ: k1
["A1","A2","A3","A4","A5"]

λ: let (k2,t2) = b 2 t1
λ: k2
["A6","A7"]

λ: let (k3,t3) = b 10 t2
λ: k3
["B1","B2","B3","B4","B5","B6","B7","B8","B9","B10"]

λ: let (k4,t4) = b (-1) t3
λ: k4
[]

λ: let (k5,t5) = b 2 t4
λ: k5
["A8","A9"]

Javascript (E6) 99 103 113 121
Really you just need to store a number for each row
B=n=>{for(r=i=[-1];n>0&i++<9;)if((a=~~B[i]+n)<16)for(B[i]=a;n--;)r[n]='ABCDEFGHIJ'[i]+a--;return r}

Test
'5:'+B(5)+'\n2:'+B(2)+'\n10:'+B(10)+'\n0:'+B(0)+'\n1:'+B(-1))+'\n3:'+B(3)

Ungolfed
B = n => {
  for (r = i = [-1]; n > 0 & i++ < 9;)
    if ((a = ~~B[i] + n) < 16)
      for (B[i] = a; n--; ) r[n] = 'ABCDEFGHIJ'[i] + a--;
  return r;
}

APL (75)
T←10 15⍴0⋄B←{(⍵∊⍳15)∧∨/Z←,T⍷⍨⍵/0:+T[P]←{⎕A[⍺],⍕⍵}/¨P←(⊃Z/,⍳⍴T)∘+¨1-⍨⍳1⍵⋄¯1}

Test:
      B 5
  A1    A2    A3    A4    A5
      B 2
  A6    A7
      B 10
  B1    B2    B3    B4    B5    B6    B7    B8    B9    B10
      B ¯1
¯1
      B 3
  A8    A9    A10

Explanation:

T←10 15⍴0: T is a 15-by-10 matrix that holds the theater state (0 = free)
B←{...}: the function

(⍵∊⍳15): if ⍵ is a member of the set of integers from 1 to 15,
∨/Z←,T⍷⍨⍵/0: and T contains ⍵ zeroes in a row (storing possible start points in Z),
:: then:

(⊃Z/,⍳⍴T): select possible start coordinates, and take the first one,
∘+¨1-⍨⍳1⍵: add ⍵-1 more positions to the right of the start coordinate
P←: store the coordinates in P
{⎕A[⍺],⍕⍵}/¨: format the coordinates
T[P]←: store the formatted coordinates at their places in T. (any nonzero values in T will do)
+: return the result, which is the formatted coordinates (the result of an assignment is tacit by default)

⋄¯1: otherwise, return ¯1.

JavaScript (ECMAScript 6 Draft) - 96 95 91 Characters
A recursive solution:
Version 1
B=(n,r=0)=>n>0&&(k=~~B[r])+n<16?[...Array(n)].map(_=>'ABCDEFGHIJ'[r]+(B[r]=++k)):r<9?B(n,r+1):-1

Version 2:
B=(n,r=0)=>n<1|r>9?-1:(k=B[r]|0)+n<16?[...Array(n)].map(_=>'ABCDEFGHIJ'[r]+(B[r]=++k)):B(n,r+1)

(Thanks to nderscore for the inspiration for the 1 character saving)
Version 3:
B=(n,r=0)=>n<1|r>9?-1:(B[r]^=0)+n<16?[...Array(n)].map(_=>'ABCDEFGHIJ'[r]+ ++B[r]):B(n,r+1)

(Thanks to nderscore)
Explanation:
B = function(n,r=0)          // Create a function B with arguments:
                             // - n is the number of seats to book
                             // - r is the row number (defaults to 0)
{
  var k = ~~B[r];            // get the number of seats already booked in row r
  if (  n > 0                // ensure that n is a valid booking
     && k+n<16 )             // check that there are enough seats remaining in row r
  {
    var P = new Array(n);    // Create an array with length n with no elements initialised
    var Q = [...P];          // Use P to create an array with every element
                             // initialised to undefined
    var R = 'ABCDEFGHIJ'[r]; // get the row ID.
    B[r] = k + n;            // Increment the number of seats booked in row r by n.
    var S = Q.map(
      function(){
        return R + (++k);    // Map each value of Q to the row ID concatenated with
                             // the seat number.
      }
    );
    return S;                // Return the array of seats.
  }
  else if ( r < 9 )          // If there are more rows to check
  {
    return B(n,r+1);         // Check the next row.
  }
  else                       // Else (if n is invalid or we've run out of rows)
  {
    return -1;               // Return -1.
  }
}

Nice solution. I was working on something similar. Here's -1 byte: B=(n,r=0)=>n>0&r<9?(k=B[r]|0)+n<16?[...Array(n)].map(_=>'ABCDEFGHIJ'[r]+(B[r]=++k)):B(n,r+1):-1

Thanks, unfortunately that one doesn't quite work as you can't book row J but negating the first check to give B=(n,r=0)=>n<1|r>9?-1:(k=B[r]|0)+n<16?[...Array(n)].map(_=>'ABCDEFGHIJ'[r]+(B[r]=++k)):B(n,r+1) should work.

Ah, good catch.

And it keeps going lower... (91) B=(n,r=0)=>n<1|r>9?-1:(B[r]^=0)+n<16?[...Array(n)].map(_=>'ABCDEFGHIJ'[r]+ ++B[r]):B(n,r+1)

GolfScript, 103 82 bytes
226,1>15/[0]*:T{:&0>{T[{),&~)>:|T\/,2=}?]{T|-:T;|{(.[15/65+]\15%)`+}%}-1if}-1if}:B

Examples
$ cat theatre.gs
226,1>15/[0]*:T
{:&0>{T[{),&~)>:|T\/,2=}?]{T|-:T;|{(.[15/65+]\15%)`+}%}-1if}-1if}:B

5  B p  # Execute B(5), stringify and print.
2  B p
15 B p
17 B p
0  B p

{}:puts # Disable automatic output.
$
$ golfscript theatre.gs
["A1" "A2" "A3" "A4" "A5"]
["A6" "A7"]
["B1" "B2" "B3" "B4" "B5" "B6" "B7" "B8" "B9" "B10" "B11" "B12" "B13" "B14" "B15"]
-1
-1

How it works
226,1>           # Push the array [ 1 … 225 ].
15/[0]*          # Split in chunks of 15 elements and join separating by zeros.
:T               # Save result in T.
{                #
  :&0>           # Save the function's argument in & and check if it's positive.
  {              # If it is:
    T[{          # For each seat S in T:
      ),         # Push [ 0 … S ].
      &~)>       # Reduce two [ S-(&-1) … S ].
      :|         # Save the result in |.
      T\/        # Split T around |.
      ,2=        # If there are two chunks, the seats are available.
    }?]          # Find the first S that satisfies the above condition.
    {            # If there was a match:
      T|-:T;     # Remove the seats in | from T.
      |{         # For each seat S in |:
        (.       # Push S+1 S+1.
        [15/65+] # Compute (S+1)/15+65; the ASCII character corresponding to the row.
        \15%)`+  # Compute (S+1)%15+1, stringify and concatenate.
      }%         #
    }            #
    -1if         # If there was no match, push -1 instead.
  }              #
  -1if           # If the argument was non-positive, push -1 instead.
}

CoffeeScript - 171 150 149
I suspect Ruby or Perl will beat this out before long.
c=0;l=64;k=1
f=(n)->
 if n<0 or n>15 or 150-c<n
  return-1
 a=[]
 for i in[1..n]
  if c%15==0
   ++l;k=1
  ++c;a.push String.fromCharCode(l)+k;++k
 a

Equivalent JavaScript/Explanation:
For those unfamiliar with CoffeeScript.
var seats  = 0; //Occupied seats.
var letter = 64; //ASCII code for row letter.
var index  = 1;  //Index of seat in row.

function seats( count )
{
    if( count < 0 || count > 15 || ( 150 - seats ) < count )
        return -1;

    var assignedSeats = [];

    for( var i = 1; i <= count; ++i )
    {
        if( ( seats % 15 ) === 0 )
        {
            ++letter;
            index = 1;
        }

        ++seats; //Occupy a seat.
        assignedSeats.push( String.fromCharCode( letter ) + index );
        ++index;
    }

    return assignedSeats;
}

Try it online.

This solution doesn't satisfy the rule All seats in one booking must be in the same row, next to each other.

Cobra - 309
This should do it, but I can't actually get to a compiler for a few hours, so I'll update it later if needed.
class P
    var s=List<of List<of String>>()
    def main
        for l in 'ABCDEFGHIJ'
            t=[]
            for n in 1:16,t.insert(0,l.toString+n.toString)
            .s.add(t)
    def b(n) as List<of String>
        t=[]
        for r in .s.count,if .s[r].count>=n
            for i in n,t.add(.s[r].pop)
            break
        return if(n>0 and t<>[],t,['-1'])

C# - 289
First attempt at code golfing.
int[]s=new int[10];string[]B(int n){string[]x=new string[]{"-1"};if(n<1||n>15)return x;int m=(int)Math.Pow(2, n)-1;for(int i=0;i<10;++i){for(int j=0;j<15-n;++j){if((s[i] &m)==0){s[i]|=m;string[]r=new string[n];for(int k=0;k<n;++k)r[k]=(""+(char)(i+65)+(j+k+1));return r;}m<<=1;}}return x;}

Un-golfed
int[] s = new int[10];
string[] B(int n)
{
    string[] x = new string[] { "-1" };
    if (n < 1 || n > 15) return x;
    int m = (int)Math.Pow(2, n) - 1;
    for (int i = 0; i < 10; ++i)
    {
        for (int j = 0; j < 15 - n; ++j)
        {
            if ((s[i] & m) == 0)
            {
                s[i] |= m;
                string[] r = new string[n];
                for (int k = 0; k < n; ++k)
                    r[k] = ("" + (char)(i + 65) + (j+k+1));
                return r;
            }
            m <<= 1;
        }
    }
    return x;
}

K, 140
d:10#,15#0b
B:{if[(x<0)|x>15;:-1];$[^r:*&&/'~:^a:{(*&&/'{x(!1+(#x)-y)+\:!y}[d x;y])+!y}[;x]'!#d;-1;[.[`d;(r;a r);~:];(10#.Q.A)[r],/:$1+a r]]}

There are undoubtedly numerous improvements to be made here

C++ - 257
Also a first attempt at golfing.
static vector< int > t (10, 0);

vector<string> b(int n){
    vector<string> o;
    int i=0,j;
    for(;i<10&&16>n&&n>0;i++){
        if(15-t[i]<n) continue;
        char l='A'+i;
        for(j=t[i];j<n+t[i];j++){
           o.push_back(l + toS(j + 1));
        }
        t[i]+=n;
        n=0;
    }
    if(o.empty()) o.push_back("-1");
    return o;
}

Because to_string wasn't working with my compiler, toS is defined as
string toS(int i){
    return static_cast<ostringstream*>( &(ostringstream() << i) )->str();
}

And as a little interface
int main(){
int input = 0;
bool done = false;
while (!done){
    cout << "how many seats would you like? (0 to exit)\n";
    cin >> input;
    vector<string> selection = b(input);
    for (auto s : selection){
        cout << s << ' ';
    }
    cout << endl;
    if (input == 0) break;
}
return 0;
}

Just removing unnecessary whitespace brings it down to 243 characters.

More golfing to 236: vector<int> t(10,0);vector<string> b(int n){vector<string> o;for(int i=0,j;i<10&&16>n&&n>0;i++){if(15-t[i]<n)continue;char l='A'+i;for(j=0;j<n;j++)o.push_back(l+to_string(j+t[i]+1));t[i]+=n;n=0;}if(o.empty())o.push_back("-1");return o;}

C# - 268 Bytes
Golfed code:
int[]s=new int[10];string[]B(int n){string[]x={"-1"};if(n<1||n>15)return x;int m=(int)Math.Pow(2,n)-1;for(int i=0;++i<10;){for(int j=0;++j<15-n;){if((s[i]&m)==0){s[i]|=m;var r=new string[n];for(int k=0;++k<n;)r[k]=(""+(char)(i+65)+(j+k+1));return r;}m<<=1;}}return x;}

Ungolfed code:
    int[] s = new int[10];
    string[] B(int n)
    {
        string[] x = { "-1" };
        if (n < 1 || n > 15) return x;
        int m = (int)Math.Pow(2, n) - 1;
        for (int i = 0; ++i < 10;)
        {
            for (int j = 0; ++j < 15 - n;)
            {
                if ((s[i] & m) == 0)
                {
                    s[i] |= m;
                    var r = new string[n];
                    for (int k = 0; ++k < n;)
                        r[k] = ("" + (char)(i + 65) + (j + k + 1));
                    return r;
                }
                m <<= 1;
            }
        }
        return x;
    }

I would have written some annotations into a comment on GoldenDragon's solution instead of making my own, but my reputation doesn't allow it.

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


text:
Giant Babylonian Matrices
Introduction
The Babylonians had a clever method for finding square roots.  To find the square root of a number N, you start with a guess, then refine it by repeatedly evaluating a line of computer code (or papyrus scroll equivalent):
guess = (guess + N/guess) / 2

If the guess is smaller than sqrt(N), N/guess must be larger than sqrt(N), so averaging these two terms should get you closer to the true answer.  It turns out this method converges fairly quickly to the correct answer:
N = 7
guess = 1
guess = 4.0
guess = 2.875
guess = 2.65489
guess = 2.64577
guess = 2.64575
guess = 2.64575

Extension
Does an equivalent algorithm exist for matrices?  Throwing all mathematical rigor aside, if we wish to find the 'square root' of a square matrix M, we may again start with a guess, then refine it by repeatedly evaluating a line of code:
guess = (guess + inverse(guess)*M) / 2

where inverse() is the matrix inverse function, and * is matrix multiplication.  Instead of 1, our initial guess is an identity matrix of the appropriate size.
However, convergence is no longer guaranteed - the algorithm diverges for most (but not all) inputs.  If M produces a convergent series, it is a Babylonian matrix.  Furthermore, the converged value is actually the real square root of the matrix (i.e., guess*guess = M).
Example
Here's an example using a 2x2 matrix, showing convergence of the series:
M = [[7,2],[3,4]]
guess = [[1.,      0.      ], [0.,       1.     ]]  <-- 2x2 identity matrix
guess = [[4.,      1.      ], [1.5,      2.5    ]]
guess = [[2.85294, 0.558824], [0.838235, 2.01471]]
guess = [[2.60335, 0.449328], [0.673992, 1.92936]]
guess = [[2.58956, 0.443035], [0.664553, 1.92501]]
guess = [[2.58952, 0.443016], [0.664523, 1.92499]]
guess = [[2.58952, 0.443016], [0.664523, 1.92499]]

After only a few iterations, the series converges to within 1e-9.  After a while, it grows unstable as rounding errors add up, but the initial stability is demonstrated, which is sufficient.
Task
Your job is to find a square matrix M, populated by the integers 1 through 9, which, when given an initial guess of an identity matrix of the proper size, converges successfully.  Matrices should be submitted as comma-delimited text (or attached text files, if they are too large), with either brackets or newlines separating subsequent rows.
Rules
Even though the matrix M and starting guess use integers (mainly for display convenience), all arithmetic should be conducted using double-precision floating point.  Integer-specific operators (such as 3/2 evaluating to 1) are prohibited.
Divide-by-zero errors, singular matrices, and over/underflows cannot be used to coerce a sequence into 'converging'.  The values must be proper floating-point numbers at all times to be considered to have converged.
The algorithm is considered to have converged if an iteration produces no change larger than 1e-9, in any individual cell.
You may use external mathematics libraries for matrix inversion (no need to reinvent the wheel).
Win Condition
The winner is the largest submitted valid Babylonian matrix made of integers 1-9, after one week.  You must also submit the code you used to find the matrix.

So basically, get the code finished and fast, then run it for the rest of the week so that we can get the biggest matrix? This is not a good winning condition. Perhaps [fastest-code] would be appropriate for this (but then make sure you give a time limit AND something to make it fair across platforms with different power).

Good point.  Perhaps this was not the most well-designed puzzle.  I shall do better next time.

I see it differently as a math challenge disguised as a coding challenge, with the unstated goal of finding the rule that determines what makes the iteration converge or not, and using it to construct large Babylonian matrices.

@steveverrill, 0 isn't in 1-9.

We produce such a matrix of any dimension n. It is simply a matrix of all 1's except 2's on the diagonal.
r = range(n)
M = [[1 + (i==j) for i in r] for j in r]

Example:
n=5
M=[[2 1 1 1 1]
   [1 2 1 1 1]
   [1 1 2 1 1]
   [1 1 1 2 1]
   [1 1 1 1 2]]

 #Within 10 steps, the procedure converges to the matrix's square root
  [[ 1.28989795  0.28989795  0.28989795  0.28989795  0.28989795]
   [ 0.28989795  1.28989795  0.28989795  0.28989795  0.28989795]
   [ 0.28989795  0.28989795  1.28989795  0.28989795  0.28989795]
   [ 0.28989795  0.28989795  0.28989795  1.28989795  0.28989795]
   [ 0.28989795  0.28989795  0.28989795  0.28989795  1.28989795]]

In general, the procedure converges for matrices with positive real eigenvalues. This is because if we work in the basis of eigenvectors of the original matrix, it and all its iterates are diagonal matrices, and we can view the procedure as applying the Babylonian method to each individual diagonal entry. The starting matrix is the still the identity in this basis.
Since the Babylonian method converges only if the original value was positive, the matrix version converges when every eigenvalue is real and positive. I'm not sure what happens for complex eigenvalues.
I constructed the given matrix to have positive eigenvalues as follows. First, start with the matrix of all ones, which is rank-1, and so has a single eigenvalue (of n) and all others 0. Then, add the identity, which shifts the eigenvalues up by 1 to get (n+1,1,1,...,1). Iterating makes the eigenvalues converge to (sqrt(n+1),1,1,...,1). Note that the 1's are unchanged by each iteration.

In case the problem intended that all numbers 1-9 be used, an arbitrary matrix of 1's except diagonal >1 suffices. Sketch of proof: This matrix is symmetric and every principal minor has positive determinant (using the determinant lemma with update vectors of all ones), so by Sylvester's criterion, it is positive definite, which implies all positive real eigenvalues.

I see I was a bit hasty with this puzzle.  Would it get more interesting if the matrix was required to be asymmetric, or to use only integers 2-9?

For assymetric, I suspect I can make the diagonal entries high and change a 1 to a 2. For integers 2-9, just double my original matrix. Honestly, I think any problem of this type is liable to be attackable by math rather than computer search, so any solution is likely to extend to arbitrarily large matrices.

I guess the puzzle is just broken.  Maybe I should throw in the towel, eh?

I enjoyed it as a linear algebra problem, but it probably won't work as a coding challenge.

Here's a 10x10 Babylonian matrix as a first target:
[[9, 8, 6, 5, 1, 1, 6, 7, 1, 6],
 [8, 7, 4, 9, 9, 5, 4, 8, 5, 9],
 [7, 1, 8, 8, 6, 8, 6, 6, 4, 1],
 [7, 8, 9, 9, 5, 1, 1, 6, 9, 9],
 [6, 9, 3, 4, 1, 9, 1, 7, 4, 9],
 [9, 1, 1, 1, 5, 4, 5, 6, 7, 1],
 [8, 6, 8, 2, 4, 4, 6, 8, 2, 2],
 [5, 4, 9, 3, 3, 5, 5, 6, 4, 1],
 [2, 4, 4, 8, 6, 8, 3, 3, 7, 6],
 [3, 9, 9, 7, 7, 9, 6, 5, 1, 8]]

which converges to
[[3.20594, 1.60102, 0.237288, -0.0745693, -1.07811, -0.255869, -0.0182269, 1.70256, 0.355871, 1.11176],
 [0.62321, 1.19922, -0.514309, 2.2604, 1.96759, 1.41485, -0.066537, 1.37868, -0.613093, 1.35704],
 [0.919805, 0.453479, 2.54444, 0.717525, -0.00569383, 1.54527, 0.131113, 0.916813, 0.443482, -0.0251371],
 [0.163383, -0.597711, 0.751538, 3.69952, 2.37728, -0.578767, 1.24375, -0.0922065, 0.749781, 0.623908],
 [2.27446, 2.7975, 0.171454, -1.6263, -1.12639, 1.22686, -2.69745, 2.36239, 1.6901, 2.1349],
 [0.669566, -1.57916, -0.722141, 1.35884, 2.43496, 2.25887, 2.01205, 0.241215, 0.342665, -0.714146],
 [0.50365, 0.472729, 1.37547, 0.32966, 1.36842, 0.0550458, 2.90591, 0.520055, -0.257277, -0.347814],
 [0.205106, 0.286162, 1.89821, 0.141372, 0.521793, 0.0638244, 1.65691, 1.04034, 0.81816, -0.30955],
 [0.0679229, 1.01126, 0.553701, 0.627696, -0.0400446, 1.21608, -0.397756, 0.35419, 2.38639, 1.08573],
 [-0.200249, 2.31035, 1.89905, -0.124084, 0.0398479, 0.454703, 1.08552, -0.152166, 0.408594, 2.31063]]

and was found with this Mathematica code:
n = 10;
M = RandomInteger[{1, 9}, {n, n}];
guess = IdentityMatrix[n] // N;
result = NestList[(# + Inverse[#].M)/2 &, guess, 32];
ListPlot[Transpose[Flatten /@ result], Joined -> True]
M // MatrixForm


text:
How many paths are available?
Objective
Find out how many possible (unique) paths you can take to get from the top left of a NxN grid to the bottom right.
The program will receive either 1 integer (or 2 for -20 points bonus) as input for the gridsize.
Input has to be anywhere in the range of 1..2000.
Output will be a string containing the number of possible paths in either decimal or hex format.
Moving
You can only move in 2 directions, right and down.
Example
This example will show the possible paths in a 2x2 grid so you can see what correct paths are.

I gave each line a different color, the output for a 2x2 grid will be 6.
This will be a big number
Indeed, it will be a big number, huge, enormous, gigantic or any other word you can come up with. Just to keep the fun in the challenge you are not allowed to use any plugins, libraries, native functions or any other thing I forgot to name that allows you to handle integers that would exceed an int64. So come up for a creative way to handle this.
Restrictions
As said before you cant use anything simular to BigInteger in C# for example.
Write an algorithm to solve this problem rather than a built-in function that would destroy the challenge.
Scoring
This is codegolf so obviously the score is based on the length of your code.
Achievements

Y U NO SQR() - The program accepts non square grids ex. [4,3], [100,20] etc. Reward: -20 points + invisible baby panda
Need for Speed! - The size of the grid will not result in a significant difference in the runtime where 1 second is considered significant. Reward: -20 points + Invisible bamboo for the baby panda (you dont want him to starve right?)
IT'S OVER NINE THOUSAANNNNDD - The program accepts gridsizes over 9000 Reward: -20 points + Invisible unicorn costume (baby panda size) Coz asians love cosplay

Assumptions
You can assume the following:

The input will never be a negative integer.
The input will always be >0 and never >2000.
You will always start at [0,0] and move to [N,N]

These baby pandas are sad and lonely, I cant take care of them all by myself so I need your help. Get on with it and claim your own baby panda while theyre still fresh ^.^ (instant delivery guaranteed.)
Happy coding :D

This is just computing choose(2*N,N), right? Or, for rectangular grids, choose(M+N,N) = (M+N)!/(M!*N!). Any language with the binomial function as a built-in will trivialize it, or even factorial, as long as it also handle big numbers.

I'll edit it so that you have to calculate all the paths yourself without use of any built-in functions, that should fix it right? I already wrote that you cant use any integer types that exceed an int64.

Banning built-in functions helps. Do you have to calculate the actual paths, or just their number? I can imagine lots of ways of computing binomials/factorial that have nothing to do with paths. Regarding integer types exceeding an int64 disallowed, I don't see how one would write a solution in a language like Python whose native integer type allows huge numbers.

If one builds it in python they could check if it would exceed int64 or make sure he wont use integers at all. and what do you mean just their number? You have to output how many different ways there are to get to the bottom right. I'll put an image in there to clarify how paths run. Forgot to do that.

I don't understand how one would make a program to output an integer that can be enormous without having an integer exceed int64. Do you want the output to be a string? As I understand the problem, I imagine that most solutions will do nothing with paths and just compute product(1..2N)/product(1..N)^2 directly.

My bad, ill change the output to a number instead on an integer. bad choice of words from my end.

Hmm. For N=2000, the number will already have thousands of digits. The challenge here seems to be to build a giant calculator. Once you have that, solving the stated task should be relatively trivial.

To make it a little easier, can we output the answer in hex? It means we could work in binary (a string of int64's for example) and not have additional challenge of converting to decimal just to output, which is not very relevant to the stated problem.

I'll throw it in there, thanks for the suggestion. (that's a yes)

This question has a number of problems. Output in "any format that you like" makes this both too broad and completely trivial. And the core problem, as xnor points out, is essentially a duplicate of some existing problems which ask for multiplication: e.g. Big integer multiplication.

@PeterTaylor Indeed, I asked for hex specifically as a more machine friendly way of outputting the data, as opposed to decimal. "Any format you like" is rather broad. BTW, Roman numerals only support up to around 1000000 if I am not mistaken (using a bar to denote mulitplcation by 1000.)

@PeterTaylor in what way does it make it trivial? Not sure of the meaning so I googled it seems it can mean several things, in dutch at least.  at steveverrill I just summed up a few examples. I have no idea what methods people come up with and with "any format" I mean just the easiest thing to output as a result of their methods, like you said so you dont have the challenge of converting your data afterwards

[tag:code-golf] should have clear output formats defined, VTC as too broad.

@user80551 I'll remove the other options and just leave hex and string then, I do disagree, [tag:code-golf] is about getting short code. sometimes there is no output at all. Clear output formats is not a requirement for code-golf

"Any format" would include 18000C9000, which is a more useful way of expressing the number of staircase walks on a 9000x9000 grid than a number in hex.

Is it just me or does calculating ~1600 digit numbers in under 1 sec seem impossible? Maybe "need for speed" needs to be revised?

Or one could simply make their program sleep for smaller grid sizes, to compensate, so their program runs at the same speed each time...

Related: http://codegolf.stackexchange.com/q/1326/25180 The only difference was the restriction about big integers.

GolfScript (62 - 40 = 22 points)
~.),{!}%1/\@+{1,\{0@2$[\]zip{{+}/.10/\10%}%\[.](<+}%}*~]-1=-1%

This program takes two inputs in the form w h from stdin and outputs the result to stdout. The largest intermediate value is w+h; although GolfScript has native big integers, this uses an array of single decimal digits for the calculations.
Bonuses claimed: non-square grids and grid sizes over 9000.
Online demo
Dissection
# Stack: 'w h'
~
# Stack: w h
.),{!}%1/\@+
# Stack: [[1] [0] ... [0]] w+h  (where the array contains h [0]s)
# Loop w+h times:
{
    # Stack: nth row of Pascal's triangle. Put [0] on the stack underneath it.
    1,\
    # Update to get the (n+1)th row.
    {
        # Stack: [prev] [curr]
        # We need the 0 for the carry in
        0@2$
        # Stack: [curr] 0 [prev] [curr]
        # Group digits of prev and curr
        [\]zip
        # Simple addition
        {
            # Stack: [curr] carry-in [a b]
            # Although if the zip was of two arrays of different length,
            # it might just be [a] instead of [a b]
            {+}/.10/\10%
            # Stack: [curr] carry-out=(carry-in+a+b)/10 digit=(carry-in+a+b)%10
        }%
        # Stack: [curr] carry-out [sum]
        # We want to append the carry-out to the sum iff it's not 0
        \[.](<+
        # Stack: [curr] [sum]
    }%
    # Stack: ... [last of previous row] [next row]
}*
# Stack: garbage [[1] ... [result in little-endian]]
~]-1=-1%
# Stack: [result in big-endian]

How long does it take to run 9000x9000? I tried running 30x30 on the link you provided and it got aborted after 5 seconds without completing.

Cool... Just wondering, can you do a factorial based algorithm and still beat me? (I will be golfing my C program hard this weekend.)

@MT0, more than 12 hours.

@steveverrill, under 100 chars, so less than 60 points with the bonuses. Does 800C400 in under 2 minutes with a highest intermediate value of 7915.

C, 201-20-20=161
Completely refactored since rev 0. Bonuses claimed: non-square and over 9000.
#define B i%w][j]
char a[22000][5999];n,m,i,j,w=21669,c;main(){scanf("%d%d",&n,&m);
for(a[w/2][w/4]=1;i<w*(n+m);i+=2)for(j=5418;j--;a[1+B-=c*10)c=(a[1+B=(a[B+a[2+B+c)%48+48)>57;
printf("%s",a[w/2+n-m]);}

Algorithm
Calculating a number like 4000!/(2000!)^2 using multiplication and division seemed rather complicated to me. Instead I went for an approach based on iterating through the rows of Pascal's triangle, using only addition.
Here's an example using an int32 type, just to show the algorithm clearly:
int a[999],n,m,i,w=997;
main(){
  scanf("%d %d",&n,&m);
  a[w/2]=1;
  for(i=0;i<w*(n+m);i+=2)a[i%w+1]=a[i%w]+a[i%w+2];
  printf("%d",a[w/2+n-m]);
}

Where n+m is the number of rows of Pascal's triangle (counting the 1 at the top as row zero.) At the end of the program, a[] contains rows x and x-1 of Pascal's triangle, the even row in the even cells, and the odd row in the odd cells.
It's important that w is an odd number, so that on each pass through the array it alternates between writing to the odd and even cells. Also, it is important to ensure that the 1 used to initialise the array is not overwritten on the first pass. This requires that w/2 be even. I will explain this later.
This program will give the right answer, up to about n=m=16, after which the integer type overflows.
Ungolfed code
This works in the same way, but uses an array of char to store the decimal digits (in big endian format.)  In order to minimise the code needed to print the answer, the calculations are performed using the ASCII values (add 48 to each value.)
Note that the value of w is enough to hold rows 9000 and 8999 the same time (a total of 9001+9000=18001 big numbers.) We actually get as far as row 18000 of Pascal's triangle, so by that stage there will not be enough space in the array to hold all 9001+9000 big numbers, and some wrapping around will occur. But this does not affect the central cell of row 9000, which is the only cell we are interested in.
Besides adding whitespace, I have explicitly spelt out the #define and ungolfed w/4 to the correct value of 5417. This value is chosen because 18000C9000 has 5417 digits.
char a[22000][5999];
n,m,i,j,w=21669,c;
main(){
  scanf("%d%d",&n,&m);
  for(a[w/2][5417]=1;i<w*(n+m);i+=2)                       //Initialise array with a 1 in least significant bit of the middle cell of [a]. Loop through the numbers of each row of Pascal's triangle.
    for(j=5418;j--;a[1+i%w][j]-=c*10)                      //Loop through the digits of each number. The code to subtract 10 from the digit if carry flag `c` is executed after the following line.
      c=(a[1+i%w][j]=(a[i%w][j]+a[2+i%w][j]+c)%48+48)>57;  //Update the cell with a digit that is the sum of the ones to the left and right, taking into account the carry, and using mod 48 arithmetic in order to store the number as its ASCII code. The return value of the assigment to a[1+i%w][j] is compared with ASCII 57 (`9`) and if it is greater the carry flag `c` is set.
  printf("%s",a[w/2+n-m]);
}

Output
My first program took about an hour to print 4000C2000. This one can handle more digits and a higher number of rows to comply with the over 9000 rule. Consequently it takes about 15 hours to print 4000C2000 and would take several days to print 18000C9000.
For 2000x2000 it prints the following (formatted to 80 columns for clarity.) This can be verified to be correct here: http://www.wolframalpha.com/input/?i=4000C2000
First 50 rows of 80 zeros (total 4000) omitted
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000001662897875033835069539536
82646038155801622559738864034512798427681344501750925293497511985938004836061174
06787175851646432467983900275415704358907838322828226892377078626044702804227263
60225612674740415245206094268141079326236405795693301673758014841914146088010797
10165776274135023159100265188426666848338060694979313461996523028997743355283203
07681570747572865349817098575890269928612521344100050157521073022188690505729147
51382188762791861883958161617214384992392748400481691029679535864524592128327086
43054316262086765263594646961335049751537926540975614276702537605304524934071255
73064101385096253973516475386956779128378613359541658838021140118989221026997673
52312197112642059780157612212146003819787455505953360709346068359603711700350715
41788401648588967587345651743656288974543012791416766391390825096496908159194487
46858927217899313004799502582220660617063988223169179908327236982684836052004811
13856792890524143074688488766572261180609865630282282923756619604128170737791195
46057911790152387847927530536412500605466256862821891455217494809727772321234293
80354002249110229834175370966913440248688425483608677217484634416362795730488526
6233145705056647940287649067948285761750402006009891416640

Javascript, 318 - 20 = 298
N=prompt(),Z=6e3,D=N*2,O=Array(D),W=Array(D);function p(n){while(n.length<Z)n="0"+n;return n}function a(a,b){r="",c=0,i=Z;while(i-->0){v=a[i]- -b[i]+c,r=(v%10)+r,c=~~(v/10)}return r}O[0]=p("1");for(x=1;x<=D;x++){for(y=0;y<=x;y++)if(x==1||y==0||y==x)W[y]=p("1");else W[y]=a(O[y-1],O[y]);O=W;W=Array(D)}console.log(O[N])

It's simple add only big number and pascal's triangle.
You can run this at your browser's console, but I don't recommend. You'd better run it from command line using Node.js. If you run this with Node.js, you need to modify N=prompt() to N=YOUR_NUMBER.
It took about an hour to calculate N=2000 using Node.js (with Z=2e3). I don't know how long will it take with Z=6e3.
Since 18000C9000 is less than 6000 decimal digits, this can calculate more than N=9000. And of course digit limit can be extended.
Output (N=2000, Z=2e3, 80 columns per row)
0000000000000000000000000000000000000000000000000000000000000000000000000000000
( 9 more zero rows)
0000000166289787503383506953953682646038155801622559738864034512798427681344501
7509252934975119859380048360611740678717585164643246798390027541570435890783832
2828226892377078626044702804227263602256126747404152452060942681410793262364057
9569330167375801484191414608801079710165776274135023159100265188426666848338060
6949793134619965230289977433552832030768157074757286534981709857589026992861252
1344100050157521073022188690505729147513821887627918618839581616172143849923927
4840048169102967953586452459212832708643054316262086765263594646961335049751537
9265409756142767025376053045249340712557306410138509625397351647538695677912837
8613359541658838021140118989221026997673523121971126420597801576122121460038197
8745550595336070934606835960371170035071541788401648588967587345651743656288974
5430127914167663913908250964969081591944874685892721789931300479950258222066061
7063988223169179908327236982684836052004811138567928905241430746884887665722611
8060986563028228292375661960412817073779119546057911790152387847927530536412500
6054662568628218914552174948097277723212342938035400224911022983417537096691344
0248688425483608677217484634416362795730488526623314570505664794028764906794828
5761750402006009891416640

JavaScript (ECMAScript 6 & Typed Arrays) - Score: 269 - 20 = 249
g=(a,b)=>b?g(b,a%b):a;f=x=>{for(r=[i=0];i<x;)r[i]=++i+x;for(i in r){k=+i+1;for(j in r){r[j]/=d=g(k,r[j]);k/=d}}return r.reduce((x,y)=>{y+='';z=Int8Array(x[l='length']+y[l]);for(a=x[l];a--;)for(b=y[l];b--;){d=z[p=a+b+1]+x[a]*y[b];z[p]=d%10;z[p-1]+=d/10|0}return z},'1')}

Score:

269 Characters
Can handle large grid sizes (above 9,000) for bonus -20 points (and does the calculation for 10,000x10,000 grid in hundreds of seconds rather than in hours).

Input:
Run f(x) where x is the grid size.
Output:
A Typed Array (of Int8) where each array element contains a digit of the answer (or wrap the output in [...result].join('') to convert it to a string.)
Explanation:
Unlike the other answers, this does not rely on calculating Pascal's Triangle.
Instead it calculates C(n,k) = n!/(k!(n-k)!) and, for a n-by-n grid then the answer is C(2n,n) = (2n)!/(n!n!) however, (2n)!/n! can be simplified to the product of the numbers (n+1)...(2n) and then the division by n! can be done by cancelling common factors from those numbers before calculating the product.
g=(a,b)=>b?g(b,a%b):a;

is a function to calculate the greatest common divisor of two numbers.
f=x=>{
  for(r=[i=0];i<x;)r[i]=++i+x;
  for(i in r){
    k=+i+1;
    for(j in r){
      r[j]/=d=g(k,r[j]);
      k/=d
    }
  }
  return r.reduce((x,y)=>{..},'1')
}

The first for-loop creates an array r of the numbers (x+1)...(2x).
The second for-loop goes through the numbers 1...x and then (in the nested for-loop) finds common divisors with values in r and cancels them.
The return value then reduces r and multiplies all the values together.
The function called by reduce is:
(x,y)=>{
  y+='';
  z=Int8Array(x[l='length']+y[l]);
  for(a=x[l];a--;)
    for(b=y[l];b--;){
      d=z[p=a+b+1]+x[a]*y[b];
      z[p]=d%10;
      z[p-1]+=d/10|0
    }
  return z
}

Which creates a Typed Array to store each digit of the number and then performs long multiplication to calculate the result.
ECMAScript 5 Version:
(Chrome Friendly and a few additional modifications for performance - such as preventing multiplication by 1)
l='length'
function M(x,y){var r=new Uint8Array(x[l]+y[l]);for(a=x[l];a--;)for(b=y[l];b--;){d=r[p=a+b+1]+x[a]*y[b];r[p]=d%10;r[p-1]+=d/10|0}return r}
function g(a,b){return b?g(b,a%b):a;}
function f(x){for(r=[i=0];i<x;)r[i]=++i+x;for(i in r){k=+i+1;for(j in r){r[j]/=d=g(k,r[j]);k/=d}}return r.reduce(function(p,c){return c<2?p:M(p,c+'')},new Uint8Array([1]))}

Tests:
20x20 Grid:
time=new Date();result=f(20);console.log("Time Taken: " + (new Date()-time)/1e3 + " seconds");[...result].join('').replace(/^0+/,'');
"137846528820"
"Time Taken: 0.001 seconds"

10,000x10,000 Grid:
time=new Date();result=f(10000);console.log("Time Taken: " + (new Date()-time)/1e3 + " seconds");[...result].join('').replace(/^0+/,'');
"[encoded data, 6019 characters]"
"Time Taken: 219.353 seconds"


text:
Spirograph Time!
A Spirograph is a toy that draws hypotrochoids and epitrochoids. For this challenge, we'll just focus on the hypotrochoids.
From Wikipedia:

A hypotrochoid is a roulette traced by a point attached to a circle of radius r rolling around the inside of a fixed circle of radius R, where the point is a distance d from the center of the interior circle.

The parametric equations for them can be defined as:

Where θ is the angle formed by the horizontal and the center of the rolling circle.

Your task is to write a program that will draw the path traced by the point defined above. As input, you'll be given R, r, and d, all integers between 1 and 200 inclusive.
You can receive this input from stdin, arguments, or user input, but it cannot be hardcoded into the program. You can accept it in whatever form is most convenient for you; as strings, integers, etc.
Assume:

Input units are given in pixels.
R >= r

Output should be a graphical representation of the hypotrochoid defined by the input. No ASCII- or other text-based output is allowed. This image can be saved to a file or displayed on screen. Include a screenshot or image of the output for an input of your choosing.
You can choose any colors you like for the path/background, subject to a contrast restriction. The two colors must have HSV 'Value' component at least half the scale apart. For instance, if you're measuring HSV from [0...1], there should be at least 0.5 difference. Between [0...255] there should be a minimum 128 difference.

This is a code golf, minimum size of source code in bytes wins.

Can we assume R > r or R ≥ r? (Same for r and d.)

Congratulations on posting the 2000th question! ;-)

@m.buettner R>=r, but d is not constrained to r, and can be anywhere in the 1-200 range.

What kind of resolution are we talking about?

@KyleKanos Since input is in pixels and each has a cap of 200, It shouldn't ever be larger than 798x798, given R=200, r=1, d=200. You can size the image to the input if you want, or keep it at a constant size, as long as it's all visible.

@Geobits: whoops, didn't see the first bullet that said input in pixels.

Bit late, but if r<0, does that produce an epitrochoid?

Mathematica, 120 bytes
f[R_,r_,d_]:=ParametricPlot[p#@t+#[-p*t/r]d&/@{Cos,Sin},{t,0,2r/GCD[p=R-r,r]Pi},PlotRange->400,ImageSize->800,Axes->0>1]

Ungolfed code and example output:
If I may include the axes in the plot, I can save another 9 characters.

JavaScript (ECMAScript 6) - 312 314 Characters
document.body.appendChild(e=document.createElement("canvas"))
v=e.getContext("2d")
n=(e.width=e.height=800)/2
M=Math
P=2*M.PI
t=0
p=prompt
r=p('r')
R=p('R')-r
d=p('d')
X=x=>n+R*M.cos(t)+d*M.cos(R/r*t)
Y=x=>n+R*M.sin(t)-d*M.sin(R/r*t)
v.beginPath()
v.moveTo(X(),Y())
for(;t<R*P;v.lineTo(X(),Y()))t+=P/2e4
v.stroke()

JSFIDDLE
Example Output
r=1,R=200,d=30

I like it, but ikt's broken somehow. Try the examples in R.

Last line could be for(;t<R*P;v.lineTo(X(),Y()))t+=P/R

@edc65 It's not broken it just wasn't doing enough iterations to do a full rotation in those examples. I've increased the iterations from 9PI to R2*PI and it should be better (however, I've left the increment at PI/1000 as otherwise it would break for small values of R).

Python: 579
Summary
This is not competitive at all given the Mathematica answer, but I decided to post it anyway because the pictures are pretty and it may inspire someone or be useful to someone. Because it is so much bigger, I left it basically ungolfed. The program expects command-line input of R,r,d.
Screenshot
Here are two examples, one for (5,3,5) and one for (10,1,7)

Code
import math
import matplotlib.pyplot as P
from matplotlib.path import Path as H
import matplotlib.patches as S
import sys
a=sys.argv
(R,r,d)=int(a[1]),int(a[2]),int(a[3])
v=[]
c=[]
c.append(H.MOVETO)
t=0
while(len(v)<3 or v.count(v[-1])+v.count(v[-2])<3):
 p=t*math.pi/1000
 t+=1
 z=(R-r)*p/r
 v.append((round((R-r)*math.cos(p)+d*math.cos(z),3),round((R-r)*math.sin(p)-d*math.sin(z),3)))
 c.append(H.LINETO)
c.pop()
v.append((0,0))
c.append(H.CLOSEPOLY)
f=P.figure()
x=f.add_subplot(111)
x.add_patch(S.PathPatch(H(v,c)))
l=R+d-r
x.set_xlim(-l-1,l+1)
x.set_ylim(-l-1,l+1)
P.show()

Can you adjust the ratio? It seems that the image are compressed vertically.

Perl/Tk - 239 227
use Tk;($R,$r,$d)=@ARGV;$R-=$r;$s=$R+$d;$c=tkinit->Canvas(-width=>2*$s,-height=>2*$s)->pack;map{$a=$x;$b=$y;$x=$s+$R*cos($_/=100)+$d*cos$_*$R/$r;$y=$s+$R*sin($_)-$d*sin$_*$R/$r;$c->createLine($a,$b,$x,$y)if$a}0..628*$s;MainLoop

R=120, r=20, d=40:

R=128, r=90, d=128:

R=179, r=86, d=98:

shell script + gnuplot (153)
Most of the effort is to remove the axes and tics, set the size and range, and increase the precision. Thankfully, gnuplot is natural for golfing, so most of the commands can be abbreviated. To save characters, the output must be redirected to an image file manually.
gnuplot<<E
se t pngc si 800,800
se pa
se sa 1e4
uns bor
uns tic
a=$1-$2
b=400
p[0:2*pi][-b:b][-b:b]a*cos($2*t)+$3*cos(a*t),a*sin($2*t)-$3*sin(a*t) not
E

Calling the script with spiro.sh 175 35 25>i.png gives

GeoGebra, 87
That is, if you consider GeoGebra a valid language.
R=2
r=1
d=1
D=R-r
Curve[D*cos(t)+d*cos(D*t/r),D*sin(t)-d*sin(D*t/r),t,0,2π*r/GCD[D,r]]

Accepts input from the GeoGebra input bar, in the format <variable>=<value>, e.g. R=1000.
Note that you may need to manually change the zoom size to view the whole image.

(The thing at the bottom of the window is the input bar that I was talking about)
Try it online here.

I suppose this has the same limitation as Kyle Kanos's submission, that you can't specify the size in pixels?

@m.buettner Yes you're right... missed that

R, 80 bytes
f=function(R,r,d){a=0:1e5/1e2;D=R-r;z=D*exp(1i*a)+d*exp(-1i*D/r*a);plot(z,,'l')}

However, if one wants 'clean' figures (no axes, no labels etc), then the code will have to be slightly longer (88 characters):
f=function(R,r,d)plot((D=R-r)*exp(1i*(a=0:1e5/1e2))+d*exp(-1i*D/r*a),,'l',,,,,,'','',,F)

One code example using the longer version of f:
f(R<-179,r<-86,d<-98);title(paste("R=",R,", r=",r," d=",d,sep=""))

Some example outputs:

This doesn't take the input sizes in pixels, does it? The first example should be almost three times as large as the second.

Why all the ,??

The commas were used to separate the arguments, many of which were NULL (nothing). Here positional argument matching was used to reduce the length of the code. This of course is bad coding practice. The recommended way would be to use named argument list, such as type="l", xlabel="", etc (and get rid of the redundant commas!).

HTML + Javascript 256  286 303
Edit
Removed 1st call to moveTo, it works anyway. Could save more cutting beginPath, but then it works only the first time
Edit2
30 bytes saved thx @ӍѲꝆΛҐӍΛПҒЦꝆ
<canvas id=c></canvas>R,r,d:<input oninput="n=400;c.width=c.height=t=n+n;v=c.getContext('2d');s=this.value.split(',');r=s[1],d=s[2],R=s[0]-r;v.beginPath();for(C=Math.cos,S=Math.sin;t>0;v.lineTo(n+R*C(t)+d*C(R/r*t),n+R*S(t)-d*S(R/r*t)),t-=.02);v.stroke()">

Test
Put input in the text box (comma separated) then press tab

R,r,d:<input onchange="n=400;c.width=c.height=t=n+n;v=c.getContext('2d');s=this.value.split(',');r=s[1],d=s[2],R=s[0]-r;v.beginPath();for(C=Math.cos,S=Math.sin;t>0;v.lineTo(n+R*C(t)+d*C(R/r*t),n+R*S(t)-d*S(R/r*t)),t-=.02);v.stroke()"><canvas id=c></canvas>

Couldn't you just add an id to the canvas and use that id globally instead of having to use querySelector!

@ӍѲꝆΛҐӍΛПҒЦꝆ yeeeeees I could. It's something I was not aware of in may 2014

Wow that was way more bytes saved than I thought.

Processing, 270
import java.util.Scanner;
void setup(){size(500, 500);}
Scanner s=new Scanner(System.in);
int R=s.nextInt(),r=s.nextInt(),d=s.nextInt();
void draw(){
  int t=width/2,q=(R-r);
  for(float i=0;i<R*PI;i+=PI/2e4)
    point(q*sin(i)-d*sin(i*q/r)+t,q*cos(i)+d*cos(i*q/r)+t);
}

The input is entered via console, one number per line.
Screenshot for R=65, r=15, d=24:

C# 813, was 999
Needs some work to reduce byte count. I managed to reduce it a little.
It accepts three space separated integers from the Console.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
class P:Form
{
int R,r,d;
P(int x,int y,int z) {R=x;r=y;d=z;}
protected override void OnPaint(PaintEventArgs e)
{
if(r==0)return;
Graphics g=e.Graphics;
g.Clear(Color.Black);
int w=(int)this.Width/2;
int h=(int)this.Height/2;
List<PointF> z= new List<PointF>();
PointF pt;
double t,x,y;
double pi=Math.PI;
for (t=0;t<2*pi;t+=0.001F)
{
x=w+(R-r)*Math.Cos(t)+d*Math.Cos(((R-r)/r)*t);
y=h+(R-r)*Math.Sin(t)-d*Math.Sin(((R-r)/r)*t);
pt=new PointF((float)x,(float)y);
z.Add(pt);
}
g.DrawPolygon(Pens.Yellow,z.ToArray());
}
static void Main()
{
char[] d={' '};
string[] e = Console.ReadLine().Split(d);
Application.Run(new P(Int32.Parse(e[0]),Int32.Parse(e[1]),Int32.Parse(e[2])));
}
}

Output sample:

R, 169 characters
f=function(R,r,d){png(w=2*R,h=2*R);par(mar=rep(0,4));t=seq(0,R*pi,.01);a=R-r;x=a*cos(t)+d*cos(t*a/r);y=a*sin(t)-d*sin(t*a/r);plot(x,y,t="l",xaxs="i",yaxs="i");dev.off()}

Indented:
f=function(R,r,d){
    png(w=2*R,h=2*R) #Creates a png device of 2*R pixels by 2*R pixels
    par(mar=rep(0,4)) #Get rid of default blank margin
    t=seq(0,R*pi,.01) #theta
    a=R-r
    x=a*cos(t)+d*cos(t*a/r)
    y=a*sin(t)-d*sin(t*a/r)
    plot(x,y,t="l",xaxs="i",yaxs="i") #Plot spirograph is a plot that fits tightly to it (i. e. 2*R by 2*R)
    dev.off() #Close the png device.
}

Examples:
> f(65,15,24)

> f(120,20,40)

> f(175,35,25)

SmileBASIC, 96 bytes
INPUT R,Q,D
M=R+MAX(Q,D)
S=R-Q@L
GPSET M+S*COS(I)+D*COS(S/Q*I),M+S*SIN(I)-D*SIN(S/Q*I)I=I+1GOTO@L

Input: 50,30,50:

Befunge-98, 113 bytes
&&:00p-10p&20p"PXIF"4(10g'd:*:I10v>H40gF1+:"}`"3**`>jvI@
1(4"TURT"p04/d'*g02I/g00*p03/d'*g<^-\0/g00*g01:Fg03H:<0P

This code relies on the Fixed Point Maths (FIXP) fingerprint for some trigonometric calculations, and the Turtle Graphics (TURT) fingerprint for drawing the path of the spirograph.
The Turtle Graphics in Befunge are very similar in behaviour to the graphics in the Logo programming language. You draw with a 'turtle' (serving as your pen), which you steer around the output surface. This entails orienting the turtle in a particular direction, and then instructing it to move forward a certain distance.
In order to work with this system, I needed to adjust the original spirograph equations into something a little more turtle friendly. I'm not sure if this is the best approach, but the algorithm I came up with works something like this:
ratio = (R-r)/r
distance1 = sin(1°) * (R-r)
distance2 = sin(1° * ratio) * d
foreach angle in 0° .. 36000°:
  heading(angle)
  forward(distance1)
  heading(-ratio*angle)
  forward(distance2)

Note that this actually draws the path with a kind of zig-zag pattern, but you don't really notice unless you zoom in closely on the image.
Here's an example using the parameters R = 73, r = 51, d = 45.

I've tested the code with CCBI and cfunge, both of which produce output in the form of an SVG image. Since this is a scalable vector format, the resulting image doesn't have a pixel size as such - it just scales to fit the screen size (at least when viewed in a browser). The example above is a screen capture that has been manually cropped and scaled.
In theory the code could also work on Rc/Funge, but in that case you'd need to be running on a system with XWindows, since it'll try to render the output in a window.

wxMaxima: 110
f(R,r,d):=plot2d([parametric,(p:R-r)*cos(t)+d*cos(t*(p)/r),(p)*sin(t)-d*sin(t*(p)/r),[t,0,2*%pi*r/gcd(p,r)]]);

This is called in the interactive session via f(#,#,#). As a sample, consider f(3,2,1):

While I like the pretty output, I'm not sure how this follows "integers between 1 and 200" or "given as pixels".

Input can be integers or floats, wxMaxima will convert to float to do its work anyway, I'll update an image using integers. I'll have to think more about input as pixels too.

Yeah, I figured it would convert them internally, and that's not a problem. The integer constraint on input was mainly to get closed loops easier (they just look better imo).

Racket
#lang racket/gui
(require 2htdp/image)

(define frame (new frame%
                   [label "Spirograph"]
                   [width 300]
                   [height 300]))

(define-values (R r d) (values 50 30 10)) ; these values can be adjusted;

(new canvas% [parent frame]
     [paint-callback
      (lambda (canvas dc)
        (send dc set-scale 3 3)
        (for ((t (in-range 0 (* 10(* R pi)) 1)))
          (define tr (degrees->radians t))
          (define a (- R r))
          (define x (+ (* a (cos tr))
                       (* d (cos (* tr (/ a r))))))
          (define y (- (* a (sin tr))
                       (* d (sin (* tr (/ a r))))))
          (send dc draw-ellipse (+ x 50) (+ y 50) 1 1)))])

(send frame show #t)

Output:


text:
Thwart LZMA2 compression
Goal
Create a program or pair of programs that collectively disrupt and fix files with the intent of preventing LZMA2 from working effectively.  The disrupt and fix routines must be reciprocal, so you can recover the original file exactly.
Targets

The collected works of Shakespeare in plain UTF-8 (5,589,891 bytes)
Wikimedia Commons 2013 Picture of the Year at full resolution (1,659,847 bytes)

Compression Methods

Ubuntu/related: xz -kz5 <infile>
Windows: 7z.exe a -txz -mx5 <outfile> <infile>
Other: Use a LZMA2 compressor with compression level 5 that compresses the works of Shakespeare to 1570550 bytes ± 100 bytes.

Scoring; sum of (everything is in bytes, ls -l or dir it):

Program(s) size (whatever it takes collectively to reversibly "break"/fix the file)
Difference in size (absolute) between:

Raw collected works of Shakespeare and your modified (uncompressed) copy.
Raw photo and your modified (uncompressed) copy.

Difference in size or 0, whichever is greater between:

Raw collected works of Shakespeare minus your modified, LZMA2 compressed copy.
Raw photo minus your modified, LZMA2 compressed copy.

Example
Poorly scoring, lazily-golfed, but compliant Python 2.x example:
import sys
x = 7919 if sys.argv[1] == 'b' else -7919
i = bytearray(open(sys.argv[2], 'rb').read())
for n in range(len(i)):
    i[n] = (i[n] + x*n) % 256
o = open(sys.argv[2]+'~', 'wb').write(i)

Running...
$ python break.py b pg100.txt
$ python break.py f pg100.txt~
$ diff -s pg100.txt pg100.txt~~
Files pg100.txt and pg100.txt~~ are identical
$ python break.py b Glühwendel_brennt_durch.jpg
$ python break.py f Glühwendel_brennt_durch.jpg~
$ diff -s Glühwendel_brennt_durch.jpg Glühwendel_brennt_durch.jpg~~
Files Glühwendel_brennt_durch.jpg and Glühwendel_brennt_durch.jpg~~ are identical
$ xz -kz5 pg100.txt~
$ xz -kz5 Glühwendel_brennt_durch.jpg~
$ ls -ln
-rw-rw-r-- 1 2092 2092     194 May 23 17:37 break.py
-rw-rw-r-- 1 2092 2092 1659874 May 23 16:20 Glühwendel_brennt_durch.jpg
-rw-rw-r-- 1 2092 2092 1659874 May 23 17:39 Glühwendel_brennt_durch.jpg~
-rw-rw-r-- 1 2092 2092 1659874 May 23 17:39 Glühwendel_brennt_durch.jpg~~
-rw-rw-r-- 1 2092 2092 1646556 May 23 17:39 Glühwendel_brennt_durch.jpg~.xz
-rw-rw-r-- 1 2092 2092 5589891 May 23 17:24 pg100.txt
-rw-rw-r-- 1 2092 2092 5589891 May 23 17:39 pg100.txt~
-rw-rw-r-- 1 2092 2092 5589891 May 23 17:39 pg100.txt~~
-rw-rw-r-- 1 2092 2092 3014136 May 23 17:39 pg100.txt~.xz

Score

= 194 + abs(5589891 − 5589891) + max(5589891 − 3014136, 0) + abs(1659874 − 1659874) + max(1659874 − 1646556, 0)
= 194 + 0 + 2575755 + 0 + 13318
2,589,267 bytes.  Bad, but doing nothing to the files yields a score of 4,635,153 bytes.

Clarification
This is golf, so you are trying to minimize your score.  I'm not sure if the comments are point out a legitimate hole in my scoring or if they are because I made it too complicated.  In any case, you want the SMALLEST:

source code
difference between the uncompressed modified file and original file (e.g. if you modify it by appending a trillion 0's on the end, your score just went up a trillion bytes)
difference between the compressed modified file and original file (e.g. the more incompressible the files become, the higher your score).  A perfectly incompressible file that grows slightly or not at all will score 0.

The trolling answer: Step 1 - work out how much free disk space you have then divide that by the size of the file to get N. Step 2 - append the file to itself N times and append the number N. Step 3 - realize there's no space left to compress the file but end up with an absolute difference in filesizes of several terrabytes (or more).... [To reverse, read N from the end of the file and shrink the file to 1/Nth the size.]

@MT0: Ah I think the solution is the differences should not be absolute. If your modified file is larger that should subtract points.

@MT0 if you modify the file to make it a terabyte large, then your score will be 1 terabyte...pretty bad when you're trying to golf.

@MT0 I added a clarification to the post, does that help?

Oh that makes sense now. To be honest for some reason it is a strange scoring system. But anyways I have a good idea on how to do it, will post in a few hours

One quibble. The compressor might make a larger file if t is especially incompressible. In this case you should be rewarded, not punished, no?

@Claudiu yes, I'm not sure how to word it to avoid abuse then where you could simply inflate the size of your modified file to get deductions.  If you compare just the delta of compressed modified to noncompressed modified where an incompressible file grows by lets say 1%, then if you inflate it to 1 TB you get a -10 GB score.

@NickT Instead of giving higher score a higher compressed size than original should give 0 and if someone tries to accomplish that by adding to the size before compression your score system will penalize that already, wouldn't it?

@Sylwester true, I'll just cut it off at 0.  Edited accordingly

Python, score = 120
import sys,hashlib
i=0
for c in sys.stdin.read():sys.stdout.write(chr(ord(c)^ord(hashlib.md5(str(i)).digest()[0])));i+=1

Makes a one-time pad using md5 in counter mode.  xors the file with it.  This has the advantage that the original and disrupted files are the same size, and that the disruptor and fixer are the same program.
The compressed disrupted files are larger than the originals.

I adjusted scoring so if the zipped files are larger than their original counterparts you are not penalized and they just score 0.  Not sure which way the difference was for your files but you may wish to update the score

@NickT: updated.

C, 51=51+0+0+0+0
main(c){for(;c=~getchar();putchar(~c^rand()>>23));}

Under the golf tricks, this program loops for each byte in standard input, and does exclusive-or with an infinite pad from rand(). I tested this with rand() in libc of OpenBSD 5.5.
Usage:
./scramble <orig >scrambled
./scramble <scrambled >orig.copy

To test my program, I wrote a shell script test.sh (57 lines) to compile my program and calculate my score.
$ sh test.sh
[1/4] Compiling scramble...
/tmp//ccbcB43x.o(.text+0x6): In function `main':
: warning: rand() isn't random; consider using arc4random()
[2/4] Scrambling files...
[3/4] Compressing scrambled files...
[4/4] Checking descrambler...
SCORE: 51=51+0+0+0+0
You may wish to rm -rf tmp.9Tjw89dgCs
$ ls -l tmp.9Tjw89dgCs/
total 43032
-rw-r--r--  1 kernigh  kernigh  1659874 May 28 17:23 filament.jpg.cp
-rw-r--r--  1 kernigh  kernigh  1659874 May 28 17:23 filament.jpg.sc
-rw-r--r--  1 kernigh  kernigh  1660016 May 28 17:23 filament.jpg.sc.xz
-rw-r--r--  1 kernigh  kernigh  5589891 May 28 17:23 pg100.txt.cp
-rw-r--r--  1 kernigh  kernigh  5589891 May 28 17:23 pg100.txt.sc
-rw-r--r--  1 kernigh  kernigh  5590232 May 28 17:23 pg100.txt.sc.xz
-rwxr-xr-x  1 kernigh  kernigh     8564 May 28 17:23 scramble

Notes about rand() and the right shift
Any compression algorithm can't compress random data. I can disguise pg100.txt and filament.jpg as random data if I scramble them with a stream cipher.
My first idea was to exclusive-or plaintext with pad to make ciphertext, then store both ciphertext and pad in the scrambled file. This would increase the size of the file, and increase my score. The obvious choice is to use the same pad for every file, and store only ciphertext in the scrambled file. If I just call rand(), it uses a default seed of 1 and makes the same pad every time.
OpenBSD 5.5 defines rand() in stdlib.h and rand.c:
/* from stdlib.h */
#define RAND_MAX    0x7fffffff

/* from rand.c */
static u_int next = 1;

int
rand_r(u_int *seed)
{
    *seed = *seed * 1103515245 + 12345;
    return (*seed % ((u_int)RAND_MAX + 1));
}

int
rand(void)
{
    return (rand_r(&next));
}

This is a linear congruential generator. The big flaw is that low bits have short periods. The 1st bit has a period of 2: if you flip a coin with rand()&1, it would go heads, tails, heads, tails, and so on. The nth bit has a period of 2n. There are 31 bits, so the whole sequence has a period of 231.
LZMA2 can find patterns in short periods and compress them. The shortest code ~c^rand() takes the low 8 bits and does not prevent compression. The right shift in ~c^rand()>>9 helps, but not enough. I use ~c^rand()>>23.

~c SCORE: 4227957=40+0+0+4019391+208526
~c^rand() SCORE: 2474616=47+0+0+2463735+10834
~c^rand()>>9 SCORE: 350717=50+0+0+350667+0
~c^rand()>>23 SCORE: 51=51+0+0+0+0

BrainFuck: 129 (129+0+0+0+0)*
random.bf (linefeeds added for readability)
,+[->>>>++[<++++++++[<[<++>-]>>[>>]+>>+[-[->>+<<<[<[<<]<
+>]>[>[>>]]]<[>>[-]]>[>[-<<]>[<+<]]+<<]<[>+<-]>>-]<[-<<+
>>]<<.,+[->]>>>]]

To create unrandom.bf you need to change the last + in the second line.
Most of the code is based on Daniel B Cristofani's Rule30 based random number generator adapted to add the number to each input and to terminate when there is no more input.
*I've tested the bytes it has processed so far 212992 (processed after 12 hours) and both files turns into a 213064 compressed file. I guess it might be done by the end of the week for know for sure but I don't want to wait with posting. I'll update the score if it's wrong, but keep the solution since Rule30 rocks!
Trivia: Rule 30 was discovered by Stephen Wolfram in 1983 and according to Wikipedia it's used to produce random integers in Mathematica.
Compilation and running:
It uses exponential time and space (iterates over 32 more cells per char processed) so it requires a BrainFuck runtime that has at least 178,876,517 cells to encode the Shakespear file, do not treat non ascii as unicode, has wider than 8 bits cells and uses -1 as eof (to differ between 255 and -1). I usually use others peoples interpreters but this time I need to be a plug and promote my own:
jitbf --eof -1 -b 16 -c 200000000 random.bf < pg100.txt > pg100.txt.ran
jitbf --eof -1 -b 16 -c 200000000 random.bf < Glühwendel_brennt_durch.jpg > Glühwendel_brennt_durch.jpg.ran

jitfb compiles BrainFuck to optimized C and abuses perl Inline::C to run it.  It's bundles with my Extended BrainFuck compiler. With the cell size and width in the argument it will allocate about 400MB.

CJam, 22 bytes
G,~q{5$H$+255%_@^o}/];

This uses a lagged Fibonacci generator with recurrence relation sn = (sn-5 + sn-16) % 255 (which I selected by mistake, but it works nevertheless) and a trivial seed to generate a pseudo-random stream of bytes, which it then XORs with the input.
I've tested my code with CJam 0.6, which was published on May 1, 2014.
How it works
G,~                    e# Dump 0, 1, ... and 15 on the stack.
   q                   e# Read from STDIN.
    {             }/   e# For each character in the input.
     5$H$              e# Copy the sixth and 19th element from the stack.
         +255%         e# Push their sum modulo 255.
              _@       e# Duplicate and rotate the character on top.
                ^o     e# XOR and print.
                    ]; e# Clear the stack.

Score
$ LANG=en_US
$ alias cjam='java -jar /usr/local/share/cjam/cjam-0.6.jar'
$ cjam thwart.cjam < pg100.txt > pg100.txt~
$ cjam thwart.cjam < pg100.txt~ > pg100.txt~~
$ diff -s pg100.txt pg100.txt~~
Files pg100.txt and pg100.txt~~ are identical
$ cjam thwart.cjam < Gluehwendel_brennt_durch.jpg > Gluehwendel_brennt_durch.jpg~
$ cjam thwart.cjam < Gluehwendel_brennt_durch.jpg~ > Gluehwendel_brennt_durch.jpg~~
$ diff -s Gluehwendel_brennt_durch.jpg Gluehwendel_brennt_durch.jpg~~
Files Gluehwendel_brennt_durch.jpg and Gluehwendel_brennt_durch.jpg~~ are identical
$ xz -kz5 pg100.txt~ Gluehwendel_brennt_durch.jpg~
$ wc -c thwart.cjam pg100.txt* Gluehwendel_brennt_durch.jpg*
      22 thwart.cjam
 5589889 pg100.txt
 5589889 pg100.txt~
 5589889 pg100.txt~~
 5590232 pg100.txt~.xz
 1659874 Gluehwendel_brennt_durch.jpg
 1659874 Gluehwendel_brennt_durch.jpg~
 1659874 Gluehwendel_brennt_durch.jpg~~
 1660016 Gluehwendel_brennt_durch.jpg~.xz
28999559 total

shell script, 203
id|gpg --batch --passphrase-fd 0 --personal-compress-preferences Uncompressed $1 $2

Running it:
% sh break.sh -c pg100.txt
% sh break.sh -d pg100.txt.gpg > pg100.txt-original
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
gpg: WARNING: message was not integrity protected
% diff -s pg100.txt pg100.txt-original
Files pg100.txt and pg100.txt-original are identical
% sh break.sh -c Glühwendel_brennt_durch.jpg
% sh break.sh -d Glühwendel_brennt_durch.jpg.gpg > Glühwendel_brennt_durch.jpg-original
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
gpg: WARNING: message was not integrity protected
% diff -s Glühwendel_brennt_durch.jpg Glühwendel_brennt_durch.jpg-original
Files Glühwendel_brennt_durch.jpg and Glühwendel_brennt_durch.jpg-original are identical
% xz -kz5 Glühwendel_brennt_durch.jpg.gpg
% xz -kz5 pg100.txt.gpg
% ls -ln
total 28340
-rw-r--r-- 1 1000 1000      84 May 24 04:33 break.sh
-rw-r--r-- 1 1000 1000 1659874 Jan 19 17:22 Glühwendel_brennt_durch.jpg
-rw-r--r-- 1 1000 1000 1659943 May 24 04:46 Glühwendel_brennt_durch.jpg.gpg
-rw-r--r-- 1 1000 1000 1660084 May 24 04:46 Glühwendel_brennt_durch.jpg.gpg.xz
-rw-r--r-- 1 1000 1000 1659874 May 24 04:46 Glühwendel_brennt_durch.jpg-original
-rw-r--r-- 1 1000 1000 5589891 May 24 03:55 pg100.txt
-rw-r--r-- 1 1000 1000 5589941 May 24 04:43 pg100.txt.gpg
-rw-r--r-- 1 1000 1000 5590284 May 24 04:43 pg100.txt.gpg.xz
-rw-r--r-- 1 1000 1000 5589891 May 24 04:43 pg100.txt-original

Not very portable, but could be made at the cost of a couple of bytes. Requires PGP (an implementation with OpenSSL would be possible, too). The ~50 byte difference between encoded file and original can probably be saved.
Scoring:
84 + abs(1659874 - 1659943) + max(1659874 - 1660084, 0) + abs(5589891 - 5589941) + max(5589891 - 5590284, 0) = 203

PHP, 117 + 0 + 0 + 0 + 0 = 117
Because would you really entrust the task of mangling your data beyond recognition to any other language?
<?=substr(gmp_export(gmp_invert(2*gmp_import($s=stream_get_contents(STDIN))+1,$m=2*gmp_pow(256,strlen($s)))/2+$m),1);

While all the other solutions are based on “secure” constructions like “random number generators” or “military-grade cryptography”, this one simply interprets strings as representing odd numbers modulo 2⋅256^length, and computes their modular inverse.
Demo:
$ php thwart.php < 100.txt.utf-8 > 100.txt.utf-8~
$ php thwart.php < 100.txt.utf-8~ > 100.txt.utf-8~~
$ diff -s 100.txt.utf-8 100.txt.utf-8~~
Files 100.txt.utf-8 and 100.txt.utf-8~~ are identical
$ php thwart.php < Glühwendel_brennt_durch.jpg > Glühwendel_brennt_durch.jpg~
$ php thwart.php < Glühwendel_brennt_durch.jpg~ > Glühwendel_brennt_durch.jpg~~
$ diff -s Glühwendel_brennt_durch.jpg Glühwendel_brennt_durch.jpg~~
Files Glühwendel_brennt_durch.jpg and Glühwendel_brennt_durch.jpg~~ are identical
$ xz -kz5 100.txt.utf-8~ Glühwendel_brennt_durch.jpg~
$ wc -c *
 5589889 100.txt.utf-8
 5589889 100.txt.utf-8~
 5590232 100.txt.utf-8~.xz
 5589889 100.txt.utf-8~~
 1659874 Glühwendel_brennt_durch.jpg
 1659874 Glühwendel_brennt_durch.jpg~
 1660016 Glühwendel_brennt_durch.jpg~.xz
 1659874 Glühwendel_brennt_durch.jpg~~
     117 thwart.php
28999654 total

Python, score=183+7+6+0+0=196
The scoring penalizes you for making the file completely uncompressible, since then the compressed file is larger from the compression overhead. Thus my program makes them slightly less than totally uncompressible:
import sys
from random import randint as J,seed
x=sys.stdin.read()
seed(ord(x[1]))
n=int(2362*J(1,2)**2.359)
sys.stdout.write(x[:n]+''.join(chr(ord(c)^J(0,255))for c in x[n:]))

Result:
Laxori@Laxori-PC /cygdrive/f/Programming/lzkill
$ cat photo.jpg | python break.py > photo.jpg~; cat photo.jpg~ | python break.py > photo.jpg~~; diff photo.jpg photo.jpg~~; xz -kz5 photo.jpg~

Laxori@Laxori-PC /cygdrive/f/Programming/lzkill
$ cat pg100.txt | python break.py > pg100.txt~; cat pg100.txt~ | python break.py > pg100.txt~~; diff pg100.txt pg100.txt~~; xz -kz5 pg100.txt~

Laxori@Laxori-PC /cygdrive/f/Programming/lzkill
$ ls -l
total 28337
----------+ 1 Laxori mkpasswd     183 2014-05-24 13:43 break.py
----------+ 1 Laxori mkpasswd 5589891 2014-05-23 19:19 pg100.txt
-rw-r--r--+ 1 Laxori mkpasswd 5589891 2014-05-24 13:45 pg100.txt~
-rw-r--r--+ 1 Laxori mkpasswd 5589884 2014-05-24 13:45 pg100.txt~.xz
-rw-r--r--+ 1 Laxori mkpasswd 5589891 2014-05-24 13:45 pg100.txt~~
----------+ 1 Laxori mkpasswd 1659874 2014-05-23 19:19 photo.jpg
-rw-r--r--+ 1 Laxori mkpasswd 1659874 2014-05-24 13:44 photo.jpg~
-rw-r--r--+ 1 Laxori mkpasswd 1659880 2014-05-24 13:44 photo.jpg~.xz
-rw-r--r--+ 1 Laxori mkpasswd 1659874 2014-05-24 13:44 photo.jpg~~

Laxori@Laxori-PC /cygdrive/f/Programming/lzkill
$ python
Python 2.5.2 (r252:60911, Dec  2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 183 + abs(5589891-5589884) + abs(1659874-1659880)
196

With the current rules, there is no penalty for a compressed file being larger.  Did the rules change?  If so, such change was unfair to this program.

@kernigh: Yeah they changed after I posted it. Truly they should have been the way they are now from the start.


text:
Open source optical lattice clock
A recent question showed how Mathematica could be used to make a beautiful optical lattice clock image.  The image looks like this.

This challenge is to reproduce this image as closely as possible using as short code as possible using only easily available open source tools (and without just downloading the image or parts of it).
Rules As it is not reasonable to ask for a pixel by pixel reproduction this is a popularity contest. However, please up-vote code that is a short (in the style of code-golf) and which produces an accurate and beautiful reproduction of the image.

Wow. It's been ages since I've last used POVray. Time to refresh my memory, I guess :-)

@downvoter: why don't you like this challenge?

Maybe because they just don't like it? Maybe because OP says it's a popularity contest and then tells the populus what to do? Maybe using random open source libraries is a somewhat unclear restriction? Maybe because they don't think that image is beautiful and can't agree with the fundamental statement of the question? Maybe because it's not well formatted? (To name a few reasons.)

I had no idea what this was about, so here's the original article. http://www.nature.com/nphoton/journal/v5/n4/covers/index.html I thought maybe we had to arrange the green balls into digits. But apparently this is not the case, they are just atoms confined in potential wells by laser beams that therefore move in a determined way to tell the time. So if you did arrange them into digits, they would be the smallest in the world.

POV-Ray, 512 characters
Here's my try. I didn't manage to replicate the lighting, so I've decided to keep the variation of highlight positions rather than to put the lights further away to keep the background brighter.
The area shadow is rather low-quality. I might as well turn it off completely (and save precious characters), but if someone is willing to donate some computing power and crank up the shadow quality and/or the dither quality, I'll gladly accept.
#include"functions.inc"
camera{location<-3,5,-6>right x look_at 0 focal_point 0 aperture 1 blur_samples 9}
#macro s(p)sphere{pi*p+y/3 1 pigment{rgb<2,8,2>/9}finish{phong .5 phong_size 5 specular 1 roughness .001}}#end
#macro l(p,c)light_source{p c/8 area_light 9*x,9*z,3,3}#end l(<6,6,0>,<8,4,8>)l(<0,6,0>,<4,8,8>)
isosurface{function{y/3+pow(cos(x)*cos(z),2)/2}contained_by{box{-9,100}}pigment{tiling 1 color_map{[.9 rgb 1][1 rgb 0]}scale .5/pi}}
s(0)s(<0,0,-1>)s(<-1,0,0>)s(<0,0,2>)s(<2,0,1>)s(<2,0,3>)

Result:

ungolfed:
#version 3.7;
#include "functions.inc"
global_settings{assumed_gamma 1}
camera{
  location <-3,5,-6>
  right x //set the aspect ratio
  look_at 0
  focal_point 0 aperture 1 blur_samples 9
}

#macro l(p,c) // position, color
  light_source{
    p c/8
    area_light 9*x,9*z,3,3
  }
#end
l(<6,6,0>,<8,4,8>)
l(<0,6,0>,<4,8,8>)

isosurface{
  function{y/3+pow(cos(x)*cos(z),2)/2}
  contained_by{box{-9,100}}
  pigment{
    tiling 1
    color_map{[.9 rgb 1][1 rgb 0]}
    scale .5/pi
  }
}
#macro s(p) //position
  sphere{
    pi*p+y/3 1
    pigment{rgb<2,8,2>/9}
    //phong for the wide highlights, specular for the small ones.
    finish{phong .5 phong_size 5 specular 1 roughness .001}
  }
#end
s(0)
s(<0,0,-1>)
s(<-1,0,0>)
s(<0,0,2>)
s(<2,0,1>)
s(<2,0,3>)

P.S.: I've only counted the five line-breaks to round the character count to a perfectly round number.

Is it possible to get more of it in focus?

@Lembik reducing the aperture will enlarge the region in focus. I will try some lower values soon, but a full render takes a while.

I get a Parsing error and a Parsing warning. They are "Possible Parse Error: assumed_gamma not specified in this POV-Ray 3.7 or later
scene. Future versions of POV-Ray may consider this a fatal error. To avoid
this warning, explicitly specify 'assumed_gamma 1.0' in the global_settings
section. See the documentation for more details.
" and "Parse Warning: This scene had other declarations preceding the first #version
directive. Please be aware that as of POV-Ray 3.7, unless already specified via
an INI option, a #version is expected as the first declaration in a scene file."

@Lembik they are just warnings. I can add assumed_gamma and #version, but code golf was never about clean coding as far as I'm aware, was it?

It certainly wasn't :) (But it would be nice in any case for the ungolfed version.) I am trying it with aperture 0.5 now.

Added to the ungolfed version. The ungolfed version is without warnings now.

It actually doesn't take long at all to render on my computer. Are there any changes you would like to borrow some cpu cycles to test out?  How do you increase the shadow quality and/or the dither quality?

@Lembik you can increase the shadow quality by increasing the 3,3 (amount of source points in each direction) in the light definition. You can then add adaptive n to it, where n is the amount of recursion (9,9 adaptive 3 starts at 2x2 points, 9,9 adaptive 2 starts at 3x3 points).

The FOV quality is improved by increasing the amount of blur_samples or by antialiasing (+a0.3 in the render, where 0.3 is how much a pixel needs to differ from its neighbors before it's anti-aliased).

How about http://imgur.com/9ueRjra ?  I used  aperture 0.8 and 9,9 adaptive 3 .

@Lembik that looks better indeed!


text:
Puzzle : Find minimum resource allocation on multiple of 10 or 12 only
I have two types of notebook .

10 problems could be solved in one page, in the first notebook.
12 problems could be solved in one page, in the second notebook.

For  given n problems I have to  use pages in such a way that no space from both notebook should be wasted ever .
Taking consideration that I have to use minimum pages also . Output should return number of pages need for solving all problem , if not passible it should return -1.
Example :
Problem count :  10

Output : 1 (one page from first notebook)

Problem Count :12

Output :1 (one page from second notebook)

Problem Count : 5

Output : -1 (Not possible)

Problem Count : 22

Output : 2(one from first notebook + one from second notebook)

Problem Count: 23

Output:-1(not possible)

What is your winning criterion? You've tagged it as [code-challenge] and [popularity-contest], but the two tags are mutually exclusive. Please read their tag excerpts to know what they mean, and decide which tag to use.

If your question is a code-challenge you need to specify an objective winning criterion so as to decide the winner. You need to write something like a scoring method, and include it in your post. You can look at other [code-challenge] questions and see what that means.

Sage, 174 bytes
Golfed because the question does not specify a winning criterion.
def n(k):
 p=MixedIntegerLinearProgram(None,0);x=p.new_variable(0,0,1);p.add_constraint(x[0]*10+x[1]*12==k);p.set_objective(x[0]+x[1])
 try:return p.solve()
 except:return -1

Brief explanation:
This uses the Sage built-in linear program solver (because why not). MILP(None,0) specifies it to use the default solver for minimization (same as MILP(maximization=False) but shorter). new_variable(0,0,1) is the same as new_variable(integer=True). When there is no solution, the solver will throw an exception: MIPSolverException: 'GLPK : There is no feasible integer solution to this Linear Program', which is caught and -1 is returned.
Sample IO:
sage: n(10)
1.0
sage: n(12)
1.0
sage: n(5)
-1
sage: n(22)
2.0
sage: n(23)
-1
sage: n(9999999)
-1
sage: n(1<<31)
178956971.0

 Note that this submission may not work for some very large numbers because of floating point rounding issues.

Perl, 83
$l=$ARGV[0];for$i(0..$l){for$j(0..$l){if(10*$i+12*$j==$l){print$i+$j;exit}}}print-1

With the lack of clear winning criteria, I've decided to go for golf. I'll probably change that once things are clarified.

JavaScript (ES6), 76 bytes
n=k=>{for(i=0;i<=k;i++)for(j=0;j<=k;j++)if(10*i+12*j==k)return i+j;return-1}

A JavaScript inplementation of the Perl answer. Simple for loops, not very interesting.