Paste number 45080: Bookie Math

Paste number 45080: Bookie Math
Pasted by: Chiao
When:4 years, 9 months ago
Share:Tweet this! | http://paste.lisp.org/+YS8
Channel:None
Paste contents:
Raw Source | XML | Display As
#!/usr/bin/env python

def bet(total,maxgames,score1,score2):
    thresh = maxgames/2
    if score1 == thresh and score2 == thresh:
        return total
    if score1 > thresh or score2 > thresh:
        return 0
    return (bet(total,maxgames,score1+1,score2)+\
            bet(total,maxgames,score1,score2+1))/2

def table(n):
    thresh = n/2
    print "%8s%7s" % ("Scores", "Bet")
    for i in range(thresh+1):
        for j in range(i+1):
            print "%4s%4s%7s" % (i, j, bet(100., n, i, j))

"""
table(5)
  Scores    Bet
   0   0   37.5
   1   0   37.5
   1   1   50.0
   2   0   25.0
   2   1   50.0
   2   2  100.
"""

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.