All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

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

•  See The Solution Submitted by levik Rating: 4.1818 (11 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re(3): Simulation results | Comment 22 of 36 |
(In reply to re(2): Simulation results by Tony)

The rewrite did however make it easier for me to add a check for duplications within packet, by adding a packetChk array of 200, as follows:
RANDOMIZE TIMER
tot = 0: totI = 0
DO
REDIM c(200)
ct = 0: ctr = 0
DO
REDIM packet(5) 'Individual pack
REDIM packetChk(200)
FOR packetCnt = 1 TO 5
DO
r = INT(RND(1) * 200 + 1)
LOOP UNTIL packetChk(r) = 0 ' THIS makes sure it's not already in the packet
packetChk(r) = 1
packet(packetCnt) = r ' fill in each card in the pack
NEXT
FOR packetCnt = 1 TO 5 ' see if we already have a card
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
(I do hope the indentations show up this time--its hard to follow without them.)
This time line 3085 (to match the B run) looks like
3085 200 232.7355
for an average of 233 packets needed to complete the set, for the A result.

 Posted by Charlie on 2003-01-29 17:01:55

 Search: Search body:
Forums (0)