
Posts
204 
Joined

Last visited

Days Won
3
Content Type
Profiles
Forums
Calendar
Gallery
Blogs
Posts posted by jasen


Option Explicit
Dim Cards As Variant
Dim SumRed As Variant
Dim i As Integer
Dim j As Single
Dim SumBlack As Integer
Dim YouWin As SingleSub SuffleCards()
Dim i As Integer
Dim PosCard1 As Integer
Dim PosCard2 As Integer
Dim TempCard As Integer
Randomize
For i = 1 To 50
PosCard1 = Int((52 * Rnd))
PosCard2 = Int((52 * Rnd))
If PosCard1 <> PosCard2 Then
TempCard = Cards(PosCard1)
Cards(PosCard1) = Cards(PosCard2)
Cards(PosCard2) = TempCard
End If
Next i
End SubSub StopCardGame()
Dim xx As Integer
ReDim SumRed(52)
Const NumOfGames = 1000000
For xx = 1 To 10
YouWin = 0
Randomize
Cards = Array(1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0)
For j = 1 To NumOfGames
SuffleCards
SumRed(0) = Cards(0)
For i = 1 To 50
SumRed(i) = SumRed(i  1) + Cards(i)
SumBlack = i  SumRed(i)
If SumBlack = 26 Or SumBlack = SumRed(i) + xx Then
If Cards(i + 1) = 1 Then YouWin = YouWin + 1
GoTo gameOver
End If
Next i
If Cards(51) = 1 Then
YouWin = YouWin + 1
GoTo gameOver
End If
gameOver:
Next j
Selection.TypeText Text:=vbCrLf + win + str(YouWin) + " times of " + str(NumOfGames) + " games with " + str(xx) + " more black"
Next xx
End SubI change my answer
With The simulation Above I get this result
win 500096 times of 1000000 games with 1 more black
win 500356 times of 1000000 games with 2 more black
win 500055 times of 1000000 games with 3 more black
win 500070 times of 1000000 games with 4 more black
win 499398 times of 1000000 games with 5 more black
win 500050 times of 1000000 games with 6 more black
win 499553 times of 1000000 games with 7 more black
win 499117 times of 1000000 games with 8 more black
win 499168 times of 1000000 games with 9 more black
win 500105 times of 1000000 games with 10 more blackSo, I think there is no best strategy.

in my computer simulation
the best strategy is
1. anytime you find 2 black more then red (such as 4B 2R) then you stop the dealer
2. or all black has appear then stop the dealer
3. but if until last card no condition above appear then bet for last card.and you will win with probability 50.030%. (veryvery small)
I've tried many combination, like 1 black more, or 3 black more, or combination of them, but those do not better then solution above.

Ok I try again
Use base 3 numbering, from 0 to 22220 to the barrels
Example: barrel no 10201 means :
Soldier 1 and 5 drink at time 0
Soldier 3 drink at time 24Barrel no 22010 means :
Soldier 4 drink at time 0
Soldier 1,2 drink at time 24Now to identify which barrel poisonous is like this :
if soldier 3 died first (form time 0 to 24)
then soldier 1 and 5 died (from time 24 to 48)
Means : barel no 20102 (or 173 (base 10)) poisionous 
Hidden Content
Kman is right
I was thought shooting skill when open eyes is not important, but I was wrong.
I have created VBA code to test this, and this agree with Kman answer
Sub AccuracyTest()
Dim win As Single
Dim cnt As Double
Dim Shot As Integer
Const openEyes = 37 'percentage if open eyes
Const divFactor = 5 'divison factor if closed eyes
Const NumOfGames = 1000000
Const NumOfTries = 6'test open eyes
win = 0
For cnt = 1 To NumOfGames
Shot = Int(100 * Rnd)
If Shot < openEyes Then win = win + 1
Next cnt
Selection.TypeText Text:=vbCrLf + str(win / NumOfGames)
'test closed eyes
win = 0
For cnt = 1 To NumOfGames
For j = 1 To NumOfTries
Shot = Int(100 * divFactor * Rnd)
If Shot < openEyes Then
win = win + 1
GoTo finish
End If
Next j
finish:
Next cnt
Selection.TypeText Text:=str(win / NumOfGames)
End Sub 
No more try to answer?

Correction
Then each group divided into 5 more smaller group
I mean 4 more smaller group, not 5.

from bubbled question, I need only 4 soldier !!
The 240 barrels of wine is divided into 4 group (each group with 60 barrels), Let say group A to Group D
Each soldier drink a spoon of all wine from 1 group. Soldier A drink from group A, and so on.
Then each group divided into 4 smaller group (each group with 15 barrels), Let say group AA to group DD
6 hour latter. Each soldier drink a spoon of all wine from 1 group in each bigger group. Soldier A drink from group AA, and so on.
Then each group divided into 5 more smaller group (each group with 4 or 3 barrels), Let say group AAA to group EEE
6 hour latter. Each soldier drink a spoon of all wine from 1 group in each bigger group. Soldier A drink from group AAA, and so on.
Then each group divided into 5 more smaller group (each group with only 1 barrel), Let say group AAAA to group EEEE
6 hour latter. Each soldier drink a spoon of wine from 1 group in each bigger group. Soldier A drink from group AAAA, and so on
from the time each soldier died the King can identify which barrel is poisonous

How many bottles of wine will be served In the party ?
If only 1, the King just need 1 soldier.
if the soldier poisoned, so the wine that the soldier take is poisonous, serve other 999 bottles
if the soldier is not poisoned, so serve 1 bottles.

There is an advantage to student A, where he can win in the first roll.
If we do not allow student A (12) win in the first roll, so the probability is 50:50

i'd say its
A good start.
Someone has create a program to list all the possibility and there are only 1/3 possibilities of your answer.
Check this site https://sinustrom.info/2012/05/21/androidunlockpatternsecurityanalysis/

I want to solidify the idea of using expected speeds to establish the accuracy of the (1/2)(3/4) ... formula
[1] It gives an exact result. As does the formula. So if there's any difference, no matter how small, it's wrong. It must agree exactly with the formula in order to be correct. That criterion is not available to us when we compare the formula to the result of a finite number of random cases.
[2] It gives the correct result for the fourbullet case, as shown here:
Hidden Content
Very clear explaination Bonanova. and the formula is a beautiful math equation.
You said it is a conjecture, I wonder why nobody has proved it mathematically.

I'm going with:
Hidden Content
Right !
Now I modifiy the question
One day on a shooting game, you are given two options
1. You only have 1 chance shooting a target with open eyes.
2. You are given 6 chances shooting the target with closed eyes.
You realize that your shooting ability is only 1/5 with closed eyes than open eyes.What option do you take to maximize your chance to win?

One day on a shooting game, you are given two choices.
1. You only have 1 chance shooting a target with open eyes.
2. You are given 3 chances shooting the target with closed eyes.
You realize that your shooting ability is only 1/3 with closed eyes than open eyes.What choice do you take to maximize your probability to win?

Yes, based on the fact that Human can never find "theory of everything" scientifically. Only religion can.

2 Alibi
1. Chalk dust is the key. When I meet the Professor, I'm clean, no chalk dust anymore on my body, so I'm not the killer.
2. If I'm the killer, I will not call the police. I will go immediately, so nobody knows the killer.

The Android unlock pattern
The Android unlock pattern has 9 dots on the screen organized in a 3×3 matrix. To unlock the phone a so called pattern has to be drawn on the screen, which means connecting certain points in a certain order. So how many valid patterns are there? For this let’s first observe the rules of pattern drawing:
at minimum 4 dots have to be used
at maximum 9 dots can be used
one dot can be used only once
the order in which the dots are connected matters (thus making it a directed graph)
dots are connected with a straight line meaning that all points on the path of the line get connected
The last rule introduces some conditional connection paths. When connecting two points with a straight line it is valid only if there is no unused point in the way. For example: you cannot connect points 1 and 3 unless point 2 is already is used. So by default drawing a line from 1 to 3 will result in the pattern 1→2→3. However if point 2 is used the transition 1→3 becomes valid, such as in 2→1→3, making a previously invalid transition valid (1→3).Also what some people seem to omit is that connecting points in a slight diagonal is possible (especially on Android 4, since the dots became smaller) such as 2→7.

Error! I left out a case: corrected cases are:
Hidden Content
20000 samples of this yields 0.371. This is close enough to bonanova's statement of 3/8 being spot on, that I'm looking forward EAGERLY to the simple analytical explanation :)
CaptainEd, before creating the code above, I also thinking like you, but then I reliaze the question is not that hard.
Look at again at prop 1 and 2
 Every second, a gun shoots a bullet along a straight line.
 Each bullet has a random speed between 0 and 1 > I guest bonanova means 0 m/s to 1m/s (not 0 to invinity)
which means that if V3> v2 > v1 then second bullet will hit first bullet, before third bullet fired.

And for 4 bullets are
P of all anhilated = 0.374813
P of all anhilated = 0.374194
P of all anhilated = 0.375763so I conclude the probability is 37.5 percent

Sorry, I was misunderstanding the question.
I have VBA create this code, I think this time I'm right
Sub RandomBulletTest()
Dim Anhilated As Integer
Dim Bullets As Variant
Dim AllAnhilated As Single
Dim TotalBullets As Integer
Bullets = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2)
For Cnt = 1 To 1000000
''random inisial speed between 0 to 1
For i = 0 To 9
Bullets(i) = Rnd
Next i
TotalBullets = 10
' value 2 for anhilated bullets
ulang:
For i = 0 To TotalBullets
If Bullets(i) < Bullets(i + 1) Then
TotalBullets = TotalBullets  2
For j = i To TotalBullets
Bullets(j) = Bullets(j + 2)
Next j
Bullets(TotalBullets + 1) = 2
Bullets(TotalBullets + 2) = 2
GoTo ulang
End If
Next i
finish:
'check how many bullet anhilated
For i = 0 To 9
If Bullets(i) < 0 Then
Anhilated = Anhilated + 1
End If
Next i
'test wheather all bullet anhilated or not
If Anhilated = 10 Then
AllAnhilated = AllAnhilated + 1
End If
Anhilated = 0
Next Cnt
Selection.TypeText Text:=" P of all anhilated = " + str(AllAnhilated / 1000000)
End Sub
3 times running the code the results are
P of all anhilated = 0.245612
P of all anhilated = 0.245541
P of all anhilated = 0.246631so I conclude the probability is 24.6 percent

Thank You bubbled, Now I know my Mistake.
In my code I didn't set newValue to 0 before asign it to lastValue
After using the modified code, I get same result as Markov chain proof
Three times running the modified code, I get this result :
0.537232
0.5372334
0.5372318 
It doesn't look iike you allow for a roll where player 1 can win and player 2 can't (the first roll).
Your procedure for a game should be this:
While Winner = 0
LastValue1 = NewValue1
LastValue2 = NewValue2
NewValue1 = Int((6 * Rnd) + 1)
NewValue2 = Int((6 * Rnd) + 1)
If NewValue1 = 6 And NewValue2 = 6 Then Winner = 1
If NewValue1 + NewValue2 = 7 And LastValue1 + LastValue2 = 7 Then Winner = 2
WendI have checked back my code, and I think nothing wrong there. Student A still can win even at first roll.

I think just sort all the half sphere, then merge the lightest with the heavyest as 1 pair, Keep the procedure 4 times.

Simulation by VBA :
Sub RandomBulletTest()
Dim Anhilated As Integer
Dim Bullets As Variant
Dim AllAnhilated As Single
Bullets = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
For Cnt = 1 To 500000
''random inisial speed between 0 to 1
For i = 0 To 9
Bullets(i) = Rnd
Next i
' i for front bullet and j for bullet behind i
' if speed j > speed i then both bullets anhilated
' i assign 2 for anhilated bullets
For i = 0 To 9
For j = i + 1 To 9
If Bullets(i) >= 0 Then
If Bullets(j) >= 0 And Bullets(j) > Bullets(i) Then
Bullets(j) = 2
Bullets(i) = 2
j = 10
End If
End If
Next j
Next i
'check how many bullet anhilated
For i = 0 To 9
If Bullets(i) < 0 Then
Anhilated = Anhilated + 1
End If
Next i
'test wheather all bullet anhilated or not
If Anhilated = 10 Then
AllAnhilated = AllAnhilated + 1
End If
Anhilated = 0
Next Cnt
Selection.TypeText Text:=" P of all anhilated = " + str(AllAnhilated / 5000000)
End Sub
P of all anhilated = .0349778
P of all anhilated = .0349992
P of all anhilated = .0350404 
Sory I thought I was wrong, The code should be like this :
Sub BadmintonTest()
Dim JohnWin As Single
Dim JulieWin As Single
Dim P5of9 As Single
Dim P4of7 As Single
Randomize
For i = 1 To 500000
For j = 1 To 9
NewValue = Int((2 * Rnd) + 1)
If NewValue = 1 Then JohnWin = JohnWin + 1
If NewValue = 2 Then JulieWin = JulieWin + 1
Next j
If JulieWin = 5 Then P5of9 = P5of9 + 1
JulieWin = 0
Next i
Selection.TypeText Text:=" percentage 5of9 = " + str(P5of9 / 5000000)For i = 1 To 500000
For j = 1 To 7
NewValue = Int((2 * Rnd) + 1)
If NewValue = 1 Then JohnWin = JohnWin + 1
If NewValue = 2 Then JulieWin = JulieWin + 1
Next j
If JulieWin = 4 Then P4of7 = P4of7 + 1
JulieWin = 0
Next i
Selection.TypeText Text:=" percentage 4of7 = " + str(P4of7 / 5000000)
End Sub
after 3 times I get this :
percentage 5of9 = .0245682 percentage 4of7 = .0274882
percentage 5of9 = .0246054 percentage 4of7 = .0273542
percentage 5of9 = .0245194 percentage 4of7 = .027356So it more likely that julie will win 4 out of 7 games than 5 out of 9
Bloody Roulette game
in New Logic/Math Puzzles
Posted · Edited by jasen
In a bloody Roulette game, usually a gun with even bullet's holes is used,
then the gun is fired alternately to the head of 2 player.
This is a fair game, because if the bullet is in odd hole so the first shooter will win,
but if the bullet is in even hole so the second shooter will win.
Now, How if we use 2 guns ?
first gun has 1 more hole then second gun.
(such as 1^{st }gun 6 hole and 2^{nd} gun 5 holes)
first player hold first gun and shoot first.
both player shoot alternately.
Is this a fair game or not?
If not who has bigger chance to win?