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

Home > Probability
Colored Candy Choice (Posted on 2016-05-25) Difficulty: 3 of 5
I have 6 pieces of candy: two each of 3 different colors. They taste especially good if eaten two at a time, provided the colors are different.

These candies are in an opaque bag from which I pick two at a time. If they are different colors I eat them together (yum) but if they are the same I put them back in and draw again. I will repeat this process to eat two more.

What is the probability the last two candies will be of differing colors?

Repeat with two each of 4 colors.
Repeat with two each of 5 colors.

No Solution Yet Submitted by Jer    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
re: Second part | Comment 7 of 10 |
(In reply to Second part by armando)

A simulation


DefDbl A-Z
Dim crlf$


Private Sub Form_Load()
 Form1.Visible = True
 
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 For tr = 1 To 100000
   clr$ = "aabbccdd"
   Do
    r1 = Int(Len(clr) * Rnd(1) + 1)
    r2 = Int(Len(clr) * Rnd(1) + 1)
    If Mid(clr, r1, 1) <> Mid(clr, r2, 1) Then
      If r1 > r2 Then h = r1: r1 = r2: r2 = h
      clr = Left(clr, r1 - 1) + Mid(clr, r1 + 1, r2 - r1 - 1) + Mid(clr, r2 + 1)
    End If
   Loop Until Len(clr) = 2
   If Left(clr, 1) <> Right(clr, 1) Then hitct = hitct + 1
 Next
 Text1.Text = Text1.Text & hitct / 100000
 
 Text1.Text = Text1.Text & crlf & " done"
  
End Sub


comes up with

.87736

for part 2

and a variant produces

0.88996

for part 3

throwing in a randomize timer shows these results for part 2:

0.87865
0.87578
0.87658

on successive runs.

and for part 3,

0.89272
0.89239
0.89133


  Posted by Charlie on 2016-05-25 21:05:17
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 (0)
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