Skip to content

Instantly share code, notes, and snippets.

@fowlmouth
Last active January 1, 2016 06:39
Show Gist options
  • Save fowlmouth/b6d0746c2cf1e75bd899 to your computer and use it in GitHub Desktop.
Save fowlmouth/b6d0746c2cf1e75bd899 to your computer and use it in GitHub Desktop.
Payoff 2.00x, increasing bet by 2.00x after each loss.
Bet #1 (1.00) would win 2.00; total spent = 1.00; net profit = 1.00
Bet #2 (2.00) would win 4.00; total spent = 3.00; net profit = 1.00
Bet #3 (4.00) would win 8.00; total spent = 7.00; net profit = 1.00
Bet #4 (8.00) would win 16.00; total spent = 15.00; net profit = 1.00
Bet #5 (16.00) would win 32.00; total spent = 31.00; net profit = 1.00
Bet #6 (32.00) would win 64.00; total spent = 63.00; net profit = 1.00
Bet #7 (64.00) would win 128.00; total spent = 127.00; net profit = 1.00
Bet #8 (128.00) would win 256.00; total spent = 255.00; net profit = 1.00
Bet #9 (256.00) would win 512.00; total spent = 511.00; net profit = 1.00
Bet #10 (512.00) would win 1024.00; total spent = 1023.00; net profit = 1.00
Bet #11 (1024.00) would win 2048.00; total spent = 2047.00; net profit = 1.00
Bet #12 (2048.00) would win 4096.00; total spent = 4095.00; net profit = 1.00
Bet #13 (4096.00) would win 8192.00; total spent = 8191.00; net profit = 1.00
Bet #14 (8192.00) would win 16384.00; total spent = 16383.00; net profit = 1.00
Payoff 2.00x, increasing bet by 2.50x after each loss.
Bet #1 (1.00) would win 2.00; total spent = 1.00; net profit = 1.00
Bet #2 (2.50) would win 5.00; total spent = 3.50; net profit = 1.50
Bet #3 (6.25) would win 12.50; total spent = 9.75; net profit = 2.75
Bet #4 (15.62) would win 31.25; total spent = 25.38; net profit = 5.88
Bet #5 (39.06) would win 78.12; total spent = 64.44; net profit = 13.69
Bet #6 (97.66) would win 195.31; total spent = 162.09; net profit = 33.22
Bet #7 (244.14) would win 488.28; total spent = 406.23; net profit = 82.05
Bet #8 (610.35) would win 1220.70; total spent = 1016.59; net profit = 204.12
Bet #9 (1525.88) would win 3051.76; total spent = 2542.46; net profit = 509.29
Bet #10 (3814.70) would win 7629.39; total spent = 6357.16; net profit = 1272.23
Bet #11 (9536.74) would win 19073.49; total spent = 15893.91; net profit = 3179.58
Bet #12 (23841.86) would win 47683.72; total spent = 39735.76; net profit = 7947.95
Bet #13 (59604.64) would win 119209.29; total spent = 99340.41; net profit = 19868.88
Bet #14 (149011.61) would win 298023.22; total spent = 248352.02; net profit = 49671.20
Payoff 2.00x, increasing bet by 3.00x after each loss.
Bet #1 (1.00) would win 2.00; total spent = 1.00; net profit = 1.00
Bet #2 (3.00) would win 6.00; total spent = 4.00; net profit = 2.00
Bet #3 (9.00) would win 18.00; total spent = 13.00; net profit = 5.00
Bet #4 (27.00) would win 54.00; total spent = 40.00; net profit = 14.00
Bet #5 (81.00) would win 162.00; total spent = 121.00; net profit = 41.00
Bet #6 (243.00) would win 486.00; total spent = 364.00; net profit = 122.00
Bet #7 (729.00) would win 1458.00; total spent = 1093.00; net profit = 365.00
Bet #8 (2187.00) would win 4374.00; total spent = 3280.00; net profit = 1094.00
Bet #9 (6561.00) would win 13122.00; total spent = 9841.00; net profit = 3281.00
Bet #10 (19683.00) would win 39366.00; total spent = 29524.00; net profit = 9842.00
Bet #11 (59049.00) would win 118098.00; total spent = 88573.00; net profit = 29525.00
Bet #12 (177147.00) would win 354294.00; total spent = 265720.00; net profit = 88574.00
Bet #13 (531441.00) would win 1062882.00; total spent = 797161.00; net profit = 265721.00
Bet #14 (1594323.00) would win 3188646.00; total spent = 2391484.00; net profit = 797162.00
Payoff 2.00x, increasing bet by 3.50x after each loss.
Bet #1 (1.00) would win 2.00; total spent = 1.00; net profit = 1.00
Bet #2 (3.50) would win 7.00; total spent = 4.50; net profit = 2.50
Bet #3 (12.25) would win 24.50; total spent = 16.75; net profit = 7.75
Bet #4 (42.88) would win 85.75; total spent = 59.62; net profit = 26.12
Bet #5 (150.06) would win 300.12; total spent = 209.69; net profit = 90.44
Bet #6 (525.22) would win 1050.44; total spent = 734.91; net profit = 315.53
Bet #7 (1838.27) would win 3676.53; total spent = 2573.17; net profit = 1103.36
Bet #8 (6433.93) would win 12867.86; total spent = 9007.10; net profit = 3860.76
Bet #9 (22518.75) would win 45037.51; total spent = 31525.86; net profit = 13511.65
Bet #10 (78815.64) would win 157631.28; total spent = 110341.49; net profit = 47289.78
Bet #11 (275854.74) would win 551709.47; total spent = 386196.23; net profit = 165513.24
Bet #12 (965491.57) would win 1930983.15; total spent = 1351687.80; net profit = 579295.34
Bet #13 (3379220.51) would win 6758441.02; total spent = 4730908.31; net profit = 2027532.70
Bet #14 (11827271.78) would win 23654543.56; total spent = 16558180.09; net profit = 7096363.47
Payoff 2.00x, increasing bet by 4.00x after each loss.
Bet #1 (1.00) would win 2.00; total spent = 1.00; net profit = 1.00
Bet #2 (4.00) would win 8.00; total spent = 5.00; net profit = 3.00
Bet #3 (16.00) would win 32.00; total spent = 21.00; net profit = 11.00
Bet #4 (64.00) would win 128.00; total spent = 85.00; net profit = 43.00
Bet #5 (256.00) would win 512.00; total spent = 341.00; net profit = 171.00
Bet #6 (1024.00) would win 2048.00; total spent = 1365.00; net profit = 683.00
Bet #7 (4096.00) would win 8192.00; total spent = 5461.00; net profit = 2731.00
Bet #8 (16384.00) would win 32768.00; total spent = 21845.00; net profit = 10923.00
Bet #9 (65536.00) would win 131072.00; total spent = 87381.00; net profit = 43691.00
Bet #10 (262144.00) would win 524288.00; total spent = 349525.00; net profit = 174763.00
Bet #11 (1048576.00) would win 2097152.00; total spent = 1398101.00; net profit = 699051.00
Bet #12 (4194304.00) would win 8388608.00; total spent = 5592405.00; net profit = 2796203.00
Bet #13 (16777216.00) would win 33554432.00; total spent = 22369621.00; net profit = 11184811.00
Bet #14 (67108864.00) would win 134217728.00; total spent = 89478485.00; net profit = 44739243.00
bet|loss|win|net
[2x each loss]
1 1 2 +1
2 3 4 +1
4 7 8 +1
8 15 16 +1
[3x each loss]
1 1 2 +1
3 4 6 +2
9 13 16 +3
27 40 54 +14
81 121 162 +81
[4x each loss]
1 1 2 +1
4 5 8 +3
16 21 32 +11
64 85 128 +43
import math, strutils
proc computeWinning (payoff = 2.0, betIncrease = 2.0, numLosses = 0, initialBet = 1.0): float =
payoff * betIncrease.pow(numLosses.float) * initialBet
var ff_precision = 2
proc ff(f: float; prec = ff_precision): string =
formatFloat(f, ffDecimal, prec)
proc doCalcs (initialBet = 1.0, betIncrease = 2.0, numBets = 14, payoff = 2.0) =
var
betAmount = initialBet
spent = 0.0
echo "Payoff ", payoff.ff, "x, increasing bet by ", betIncrease.ff, "x after each loss."
for i in 0 .. <numBets:
spent += betAmount
let win = computeWinning(
payoff = payoff,
betIncrease = betIncrease,
numLosses = i,
initialBet = initialBet)
echo "Bet #", i+1, " (", betAmount.ff, ") would win ", win.ff, "; total spent = ", spent.ff, "; net profit = ", (win - spent).ff
betAmount = betAmount * betIncrease
echo()
discard """
doCalcs 1.0, 2.0
doCalcs 1.0, 2.5
doCalcs 1.0, 3.0
doCalcs 1.0, 3.5
doCalcs 1.0, 4.0
#"""
#docalcs 0.1, 2.25
import parseopt2
var
initialBet = 1.0
increaseFactor = 2.25
bets = 12
payoff = 2.0
for kind, k,v in getopt():
case kind
of cmdLongOption, cmdShortOption:
case k.toLower
of "initial":
initialBet = v.parseFloat
of "increase":
increaseFactor = v.parseFloat
of "bets":
bets = v.parseInt
of "payoff":
payoff = v.parseFloat
of "precision":
ff_precision = v.parseInt
else:
discard
else:
discard
doCalcs initialBet, increaseFactor, bets, payoff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment