A trading card series has 200 different cards in it, which are sold in 5-card packages.
Each package has a random sampling of the cards (assume that any card of the 200 has an equal chance of being in a package).
On the average, how many packages will need to be bought to collect the complete series if...
A: all the cards in a package will always be different
B: a package can have repeats
(In reply to
re(2): Simulation results by Tony)
I've corrected a couple of typos (pack vs packet for the array name, packCnt vs packetCnt for the iteration variable/subscript) so it looks like
RANDOMIZE TIMER
tot = 0: totI = 0
DO
REDIM c(200)
ct = 0: ctr = 0
DO
REDIM packet(5) 'Individual pack
FOR packetCnt = 1 TO 5
r = INT(RND(1) * 200 + 1)
packet(packetCnt) = r ' fill in each card in the pack
NEXT
FOR packetCnt = 1 TO 5 ' see if we already have a card (but this doesn't check from the pack)
r = packet(packetCnt)
IF c(r) = 0 THEN
c(r) = 1
ct = ct + 1 ' ct must get to 200 each trial
END IF
NEXT
ctr = ctr + 1 ' ctr is number of purchases for a complete set
IF ct = 200 THEN EXIT DO
LOOP
totI = totI + ctr ' Number of packs
numTry = numTry + 1
PRINT numTry, ctr, totI / numTry
LOOP
but this still does not have a check for non-duplication within packet. The 3085th line is
3085 296 233.7284
for an average of 234 packets per trial.
|
Posted by Charlie
on 2003-01-29 17:00:45 |