Skip to content

Instantly share code, notes, and snippets.

@Noxville
Created July 7, 2017 11:17
Show Gist options
  • Save Noxville/5d4c5f61f67e5c3b3532f39af4690f5f to your computer and use it in GitHub Desktop.
Save Noxville/5d4c5f61f67e5c3b3532f39af4690f5f to your computer and use it in GitHub Desktop.
import random
def num_in_team(ar, team_num):
c = sum(ar[5 * team_num: 5 * team_num + 5])
return c
def good(ss, gs):
ret = True
for t in xrange(6):
if num_in_team(ss, t) < 4: ret = False
for t in xrange(6,13):
if num_in_team(ss, t) < 3: ret = False
for t in xrange(13,18):
if num_in_team(ss, t) < 2: ret = False
for t in xrange(18):
if num_in_team(gs, t) == 0: ret = False
return ret
def add_cards(num, ar, refund):
ref = 0
for _ in xrange(num):
idx = random.randint(0, 89)
if ar[idx] == 1:
ref += refund
else:
ar[idx] = 1
return ref
premium = 1
N = 10000
dust, it = 0, 0
for n in xrange(N):
# array of players, in sets of 5 from favourite to least favourite team
ss, gs = [0] * 90, [0] * 90
while not good(ss, gs):
it += 1
if premium:
dust += 50
dust -= add_cards(4, ss, 2)
dust -= add_cards(1, gs, 5)
else:
dust += 6 # you refund the commons immediately
if random.random() > 0.9:
dust -= add_cards(1, gs, 5)
else:
dust -= add_cards(1, ss, 2)
print float(dust) / N, float(it) / N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment