LogFAQs > #877603515

LurkerFAQs, Active DB, Database 1 ( 03.09.2017-09.16.2017 ), DB2, DB3, DB4, DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, Clear
Topic List
Page List: 1
TopicEasy probability question. A guy has two white socks and two pink socks.
jamieyello3
04/20/17 11:43:20 PM
#36:


This program follows the same logic I was doing with the other rng, but 100,000,000 times.

Dim Match As Integer = 0
Dim NotMatch As Integer = 0
Dim Sock1 As Integer = 0
Dim Sock2 As Integer = 0

For I As Integer = 1 To 100000000
Sock1 = CInt(Int((4 * Rnd()) + 1))
Do
Sock2 = CInt(Int((4 * Rnd()) + 1))
Loop While (Sock1 = Sock2)


If ((Sock1 Mod 2) = (Sock2 Mod 2)) Then
Match += 1
Else
NotMatch += 1
End If

Next

lblMatch.Text = "Matched - " + Match.ToString()
lblNotMatch.Text = "Didn't Match - " + NotMatch.ToString()


It makes a number for sock one and sock 2. If sock 2 is the same sock as sock 1, it rerolls sock 2.

M4Oo2YM

It suggests the chances of the sock matching are exactly 1/3.

I modify it to reroll both Sock1 and Sock2 if it picks the same sock twice..

Same result.
... Copied to Clipboard!
Topic List
Page List: 1