In [1]:
import math
import random; random.seed(0)
from collections import Counter
from itertools import chain
ATTENDEES = 17000
eligible_users = [] # we will add a list of packs to this whenever we find someone who's eligible
First I'm going to define a function which gets us an attendee's spending at random. Don't worry about the implementation, just check the printed sample of 100 values generated and see if it seems realistic. I think it is, but we can argue about this, sure.
You can adjust the algorithm and see the numbers with what you feel is a realistic distribution.
In [2]:
def get_spending_of_attendee():
if random.random() < 0.03: # Let's say 3% doesn't even care about the secret shop
return 0
return int((random.paretovariate(2) - 0.5) * 100)
print([get_spending_of_attendee() for _ in range(100)])
Packs are identified by an ID of 0
to 5
, and this function just hands out
an attendee's packs based on their spending.
In [3]:
def get_packs(spending):
return [random.randint(0, 5) for _ in range(math.floor(spending / 50))]
So here's the meat of the notebook. We get a random spending, the packs for that, and try to redeem the stickers for the digital unlock. If we can't do that because of dupes, we increment our userbase by one. If someone is not constrained by dupes, they have no use for our site. This includes:
In [4]:
for _ in range(ATTENDEES):
spending = get_spending_of_attendee()
packs = get_packs(spending)
try:
while len(packs) > 5:
for pack_id in range(6):
packs.remove(pack_id)
except ValueError:
eligible_users.append(packs)
In [5]:
print(len(eligible_users))
So, yeah. We have around 1,280 people who could even use the site. But:
After all this, we're lucky to have say, a userbase of 500.
However:
In [6]:
pack_count = sum(len(get_packs(get_spending_of_attendee())) for _ in range(ATTENDEES))
print(pack_count)
There's 42,000 packs handed out, most of which go unredeemed. That'd be 7,000 completed sticker books if we could match them all up, not 1,280.