[QUIZ 5b & 5e] Date differences, and betting (Larry Clapp) [spoiler]
[QUIZ 5b & 5e] Date differences, and betting (Larry Clapp) [spoiler]
2007-07-25 01:34:15 GMT
My solution to the betting problem:
(defun bet (total maxgames score1 score2 &optional err-check-off)
(let ((thresh (floor (/ maxgames 2))))
(unless err-check-off
(cond ((evenp maxgames)
(error "Only odd numbers of total games allowed"))
((or (> score1 thresh)
(> score2 thresh))
(error "Scores must be below half the total number of games"))
((or (< maxgames 0)
(< score1 0)
(< score2 0))
(error "maxgame, score1 and score2 must not be negative"))))
(cond ((or (= score1 (1+ thresh))
(= score2 (1+ thresh)))
0)
((and (= score1 thresh)
(= score2 thresh))
total)
(t (/ (+ (bet total maxgames (1+ score1) score2 t)
(bet total maxgames score1 (1+ score2) t))
2)))))
Given the you bet $a this round, and $b / $c next round, then a
win-loss or a loss-win must put you back at the same value, meaning
that
a - b = -a +c
(Continue reading)

RSS Feed