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 (
> indicates input,
< indicates output):
> 7 800
Place a bet on the number "7" only, for $800.
> 8,9,10,11 50
Place a bet on the range "8,9,10,11", for $50.
> c1 2000
Place a bet on "1st column" (1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34) for $2000.
> ok > 7
All players done. Pocketed in 7.
< 1 28800 < 2 0 < 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)
< 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.