Keep track of a Roulette game You're writing a program for a new automated roulette croupier to be installed in a major casino. Unfortunately, the last guy bailed out on the company and published buggy software. You're stuck with a thousand burned flash chips with only a few kilobytes of space to store a working program. Can you do it?

The task is to write a program which will accurately handle bets, wins and losses of a roulette game.

It will be run as a session. When it initialises, players place their bets which are sent through STDIN. Once all bets have been received, the input for where the ball landed is given. The program must then calculate the winnings for each of the players and the casino.

A single zero wheel is assumed. Assume dollars will be bet (not chips) and that the input is always valid. You only need to support the "outside bets" and numbered bets (lists of numbers, not named.) Payouts are described on the Wikipedia article.

Outside bet names: c1, c2, c3 (1st-3rd column), d1, d2, d3 (1st-3rd dozen), o (odd), e (even), r (red), b (black), 1-18, 19-36.

Example session (&gt; indicates input, &lt; indicates output):

&gt; 7 800


Place a bet on the number "7" only, for $800.

&gt; 8,9,10,11 50


Place a bet on the range "8,9,10,11", for $50.

&gt; c1 2000


Place a bet on "1st column" (1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34) for $2000.

&gt; ok
&gt; 7


All players done. Pocketed in 7.

&lt; 1 28800
&lt; 2 0
&lt; 3 6000


Payout details: #1 gets 36x original bet (35-to-1), #2 did not win and #3 gets 3x original bet (2-to-1)

&lt; c -34750


Casino is down $34,750.

Deciding the winner


Code space is critical so the smaller the program the better. The smallest program implementing all of the described features will be the winner, unless bonus features are present, in which case the best overall program will be decided based on the combination of size and features supported.
The program must implement at least the bets described above, but support for other types, as well as number bets such as splits and baskets will be considered and may add bonus points.
Python, 443 440 chars

R=range
N=37
V=91447186090
M={'e':R(0,N,2),'o':R(1,N,2),'r':[i for i in R(N)if V&gt;&gt;i&amp;1],'b':[i for i in R(1,N)if~V&gt;&gt;i&amp;1],'1-18':R(1,19),'19-36':R(19,N)}
for i in R(1,4):M['c%d'%i]=R(i,N,3);M['d%d'%i]=R(i*12-11,i*12+1)
for i in R(1,N):M[`i`]=[i]
B=[]
r=raw_input()
while'ok'!=r:x,k=r.split();B+=[(sum((M[y]for y in x.split(',')),[]),int(k))];r=raw_input()
z=input()
c=0
i=1
for b,k in B:v=36/len(b)*k*(z in b);print i,v;c+=k-v;i+=1
print'c',c


Makes M, a map from bet names to a list of numbers that win that bet.  Then it reads the bets in, storing each one as a pair (list of numbers, dollar amount) in the list B.  Finally, reads in the spin z and computes the payouts.