(In reply to
solution by Charlie)
DefDbl A-Z
Dim crlf$, c$(2)
Private Sub Form_Load()
ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
Randomize Timer
For trial = 1 To 16560
Do
bag = Int(3 * Rnd(1) + 1)
m = 0
For chce = 1 To 2
Do
marble = Int(9 * Rnd(1) + 1)
Loop Until marble <> m
m = marble
Select Case bag
Case 1
Select Case marble
Case Is <= 5
c$(chce) = "b"
Case 6 To 8
c$(chce) = "r"
Case Else
c$(chce) = "w"
End Select
Case 2
Select Case marble
Case Is <= 5
c$(chce) = "r"
Case 6 To 8
c$(chce) = "w"
Case Else
c$(chce) = "b"
End Select
Case 3
Select Case marble
Case Is <= 5
c$(chce) = "w"
Case 6 To 8
c$(chce) = "b"
Case Else
c$(chce) = "r"
End Select
End Select
Next chce
Loop Until c$(1) = "b" And c$(2) = "w"
m = 0
For chce = 1 To 2
Do
marble = Int(9 * Rnd(1) + 1)
Loop Until marble <> m
m = marble
Select Case bag
Case 1
Select Case marble
Case Is <= 5
c$(chce) = "b"
Case 6 To 8
c$(chce) = "r"
Case Else
c$(chce) = "w"
End Select
Case 2
Select Case marble
Case Is <= 5
c$(chce) = "r"
Case 6 To 8
c$(chce) = "w"
Case Else
c$(chce) = "b"
End Select
Case 3
Select Case marble
Case Is <= 5
c$(chce) = "w"
Case 6 To 8
c$(chce) = "b"
Case Else
c$(chce) = "r"
End Select
End Select
Next chce
If c$(1) = "b" And c$(2) = "w" Then hits = hits + 1
If trial Mod 1656 = 0 Then
Text1.Text = Text1.Text & Str(hits) & Str(trial) & Str(hits / trial) & crlf
End If
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
One run finds 2599 out of 16560 trials; the next, 2554 out of 16560.
|
Posted by Charlie
on 2014-08-29 12:16:17 |