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.
(In reply to Second part
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For tr = 1 To 100000
clr$ = "aabbccdd"
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)
Loop Until Len(clr) = 2
If Left(clr, 1) <> Right(clr, 1) Then hitct = hitct + 1
Text1.Text = Text1.Text & hitct / 100000
Text1.Text = Text1.Text & crlf & " done"
comes up with
for part 2
and a variant produces
for part 3
throwing in a randomize timer shows these results for part 2:
on successive runs.
and for part 3,
Posted by Charlie
on 2016-05-25 21:05:17