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

Home > General
200 Candies (Posted on 2023-12-12) Difficulty: 3 of 5
I have 200 candies in an hourglass dispenser. There are 40 each of red, white, blue, yellow and green. Each time I turn the hourglass over the candies get thoroughly mixed and 20 candies are poured into a cup. I like the blue candies best.

When I want candy, I turn over the dispenser and sort through the candies in the cup. I leave all of the blue ones in the cup and put the rest back. Then I turn over the hourglass a second time. The dispenser fills the cup so that I get exactly 20 candies, which I eat. I continue this way until the dispenser is empty.

How many blue candies will be in the final cupful?

Note:The dispenser dispense just the right amount so that to total will still be 20; so if 4 blues remain, it will dispense 16.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution simulation | Comment 2 of 9 |
The below is apparently based on misinterpretation of the procedure.

It seems to be random with a mean of 1.727, approximately:

totct=0;counts=zeros(1,21);
hourglass0=[repmat('r',1,40) ...
  repmat('w',1,40) repmat('b',1,40) ...
  repmat('y',1,40) repmat('g',1,40) ];
for i=1:1000000
  cup='';
  hourglass=hourglass0(randperm(200));
  while ~isempty(hourglass)
    if length(hourglass)<=20
      ct=sum((hourglass=='b'));
      hourglass='';
      continue
    else
      cup=hourglass(end-19:end);
      hourglass=hourglass(1:end-20);
    end

    cup(find(cup=='b'))='';
    refill=20-length(cup);

    if length(hourglass)<=refill
      ct=sum((hourglass=='b'));
      cup=[cup hourglass];
      hourglass='';
    else
      cup=[cup hourglass(end-(refill-1):end)];
      hourglass=hourglass(1:end-refill);
    end

  end
  
  totct=totct+ct;
  counts(ct+1)=counts(ct+1)+1;
end
 
fprintf('%9d/%d %10.8f ',totct, i, totct/i)
counts'



finds and average count of 1.727:

  1726547/1000000 1.72654700  
  
distributed as:  
 
 0        199284
 1        298161
 2        246558
 3        146525
 4         69482
 5         27133
 6          9126
 7          2753
 8           784
 9           147
10            38
11             8
12             1

Edited on December 12, 2023, 7:46 pm
  Posted by Charlie on 2023-12-12 14:32:28

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information