Program dafindnum.bas guesses unanswered number less or more
by starting from middle of list and comparing odd and even ones separately
Visual:
Won if you guessed less than number before attempt
or lost if you guessed from beginning faster
It is effective if distribution of guesses is normal undulating
however how to evaluate result of integral is still unknown
However experimental program is not optimal
and it is possible to include a step greater than 2
Checking 1000 or a dozen thousand showed:
Draw 25% and Lose 37.5% and Win 37.5%
So if a draw is considered a win then algorithm it is effective
picture: 10 kB
by starting from middle of list and comparing odd and even ones separately
Visual:
Code: (Select All)
123456789
5
5
5 7
3 5 7
3 5 7 9
1 3 5 7 9
1 3 567 9
1 3 567 9
1 3 56789
1 3456789
1 3456789
123456789
Won if you guessed less than number before attempt
or lost if you guessed from beginning faster
It is effective if distribution of guesses is normal undulating
however how to evaluate result of integral is still unknown
However experimental program is not optimal
and it is possible to include a step greater than 2
Code: (Select All)
n = 55: Randomize Timer: a = Int(Rnd * (n - 1)) + 1 ' dafindnum.bas
start = Int(1 + n / 2) ' https://qb64phoenix.com/forum/showthread.php?tid=900
Print "n= "; n, "a= "; a: Print: s = 0
For i = 0 To 1: For j = 0 To n / 4
t = Int(start + j * 2) + i
If t > n Then 5
s = s + 1: Print s, t
If t = a Then 25
5 t = Int(start - j * 2) + i
If t < 1 Then 15
s = s + 1: Print s, t
If t = a Then 25
15 Next: Next ': Print "NO...": End
25 Print: Print "Step="; s, "Guess="; a, "Max="; n
If s < a Then Print "WIN" Else If s > a Then Print "Lose" Else Print "Draw"
End
Checking 1000 or a dozen thousand showed:
Draw 25% and Lose 37.5% and Win 37.5%
Code: (Select All)
n = 3*10^4: start = Int(1 + n / 2) ' dafindnum99.bas
w = 0: l = 0: d = 0 ' Win Lose Draw
For a = 1 To n: s = 0
For i = 0 To 1 ' even \ odd
For j = 0 To n / 4
t = Int(start + j * 2) + i ' right
If t > n Then 5
s = s + 1
If t = a Then 25
5 t = Int(start - j * 2) + i ' left
If t < 1 Then 15
s = s + 1
If t = a Then 25
15 Next: Next ': Print "NO..." : End
25 Print "Max="; n, "Guess="; a, "Step="; s,
If s < a Then Print "WIN": w = w + 1 Else If s > a Then Print "Lose": l = l + 1 Else Print "Draw": d = d + 1
Next a: Print: Print "Win= "; w, "Lose= "; l, "Draw= "; d
End
So if a draw is considered a win then algorithm it is effective
picture: 10 kB
Write name of program in 1st line to copy & paste & save filename.bas
Insert program pictures: press print-screen-shot button
Open paint & Paste & Save as PNG
Add picture file to program topic
Russia looks world from future. Big data is peace data.
I never recommend anything & always write only about myself
Insert program pictures: press print-screen-shot button
Open paint & Paste & Save as PNG
Add picture file to program topic
Russia looks world from future. Big data is peace data.
I never recommend anything & always write only about myself