Author Topic: Guess Number  (Read 6696 times)

0 Members and 1 Guest are viewing this topic.

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Guess Number
« on: June 20, 2021, 02:22:21 am »
Theme "Guess number" has disappeared and given usefulness
I create theme again remembering programs

Later there will be a repeat of program where
computer guesses 1 out of a billion for logarithmic number of steps

Now a my curiosity:
Single-line "Guess Number" program QBasic QB64 from Russia
Code: QB64: [Select]
  1. 1 IF Russia = 0 THEN Russia = 2222: RANDOMIZE TIMER: num = INT(RND * 100) + 1: GOTO 1 ELSE IF Russia <> 0 THEN INPUT n: IF n < num THEN PRINT "MORE": GOTO 1 ELSE IF n > num THEN PRINT "less": GOTO 1 ELSE IF n = num THEN PRINT "da": END ELSE GOTO 1 'DANILIN Russia 9-9-2019 guessnum.bas
  2.  

An array of programs in many languages and a similar topic here:

http://rosettacode.org/wiki/Guess_the_number#BASIC
rosettacode.org/wiki/Guess_the_number

http://rosettacode.org/wiki/Guess_the_number/With_feedback_(player)#BASIC
rosettacode.org/wiki/Guess_the_number/With_feedback_(player)

Hi Lo without Secret Number?
https://qb64.org/forum/index.php?topic=3120.30

Update: program better view

1 IF Russia = 0 THEN Russia = 2222: RANDOMIZE TIMER: num = INT(RND * 100) + 1: GOTO 1 ELSE IF Russia <> 0 THEN INPUT n: IF n < num THEN PRINT "MORE": GOTO 1 ELSE IF n > num THEN PRINT "less": GOTO 1 ELSE IF n = num THEN PRINT "da": END ELSE GOTO 1 'DANILIN Russia 9-9-2019 guessnum.bas
« Last Edit: June 20, 2021, 07:16:46 am by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Guess Number
« Reply #1 on: June 20, 2021, 03:37:38 pm »
Missed Danilin entry for Hi Lo Game without secret number!
https://www.qb64.org/forum/index.php?topic=3120.msg123881#msg123881

And here is my one liner in case you forgot or can't find old posts like me:
Code: QB64: [Select]
  1. 1 If U = S Then S = Int(Rnd * 98) + 1: GoTo 1 Else If U <> S Then Input "0<Guess<99="; U: If U = S Then Print "=": GoTo 1 Else If U < S Then Print "+": GoTo 1 Else Print "-": GoTo 1
  2.  

US many bytes shorter than Russia one. :)
« Last Edit: June 20, 2021, 03:42:10 pm by bplus »

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Guess Number
« Reply #2 on: June 21, 2021, 12:55:37 am »
Using principle of guess number and less \ more
knowing date i found your message:

September 12, 2019, 09:59:10 AM

Your program still needs RANDOMIZE TIMER

But my message is earlier
September 12, 2019, 06:07:54 AM

Russian anecdote from 18 century:

2 athletes compete: Russian and American
American athlete finished 2nd
Russian athlete finished penultimate
« Last Edit: June 21, 2021, 01:14:07 am by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Guess Number
« Reply #3 on: June 21, 2021, 05:46:12 pm »
Quote
2 athletes compete: Russian and American
American athlete finished 2nd
Russian athlete finished penultimate

Yes that the American should finish 2nd would be more notable than the other thing mentioned last. ;-))

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Guess Number
« Reply #4 on: June 21, 2021, 07:34:02 pm »
Yes that the American should finish 2nd would be more notable than the other thing mentioned last. ;-))

Back in college, my teacher used something like this to discuss propaganda in the media.

The facts:  A race was held between an American and a Russian, and the American won.

American propaganda headline:  International Race results are in!  America comes in first.  Russia, dead last!

Russian propaganda headline: International Race results are in.  Mother Russia gets second place finish, while America comes in second to last!

*ALL* the news articles are 100% true and valid, but the *perception* they generate is what’s the propaganda — and in today’s world, we see this slant on almost *ALL* news stories.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Guess Number
« Reply #5 on: June 22, 2021, 05:12:48 am »
I welcome all answers and now

Program from year 2019 damilliiard.bas is guessing integral differential
numbers cyclopean by approaches logarithmic

It's just not clear how to go into even bigger numbers

Code: QB64: [Select]
  1. 'daMilliard.bas
  2. t = 0: h1 = 0: h2 = 10^7
  3. human = INT(RND*h2) 'human
  4. comp = 1 'INT(RND*h2) 'comp
  5. 10 t = t+1: PRINT t; "human ="; human; "     comp ="; comp;
  6. IF comp < human THEN PRINT "MORE": a = comp: comp = INT((comp+h2)/2): h1 = a: GOTO 10
  7. IF human < comp THEN PRINT "less": a = comp: comp = INT((h1+comp)/2): h2 = a: GOTO 10
  8. PRINT "win by "; t; " steps"

Results for diapason 1 from 10^7

Code: [Select]
1  human = 1326126     comp = 1928303  less
2  human = 1326126     comp = 964151  MORE
3  human = 1326126     comp = 1446227  less
4  human = 1326126     comp = 1205189  MORE
5  human = 1326126     comp = 1325708  MORE
6  human = 1326126     comp = 1385967  less
7  human = 1326126     comp = 1355837  less
8  human = 1326126     comp = 1340772  less
9  human = 1326126     comp = 1333240  less
10  human = 1326126     comp = 1329474  less
11  human = 1326126     comp = 1327591  less
12  human = 1326126     comp = 1326649  less
13  human = 1326126     comp = 1326178  less
14  human = 1326126     comp = 1325943  MORE
15  human = 1326126     comp = 1326060  MORE
16  human = 1326126     comp = 1326119  MORE
17  human = 1326126     comp = 1326148  less
18  human = 1326126     comp = 1326133  less
19  human = 1326126     comp = 1326126  win by 19 steps

Update: online compilator c#

rextester.com/BEVKB31555

In light of above: Song of Day:
« Last Edit: June 22, 2021, 06:00:48 am by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Guess Number
« Reply #6 on: June 22, 2021, 07:44:38 am »
Care to try Floats? :)

I am thinking of a number between 1 and 2...

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Guess Number
« Reply #7 on: June 22, 2021, 11:14:06 am »
Care to try Floats? :)

I am thinking of a number between 1 and 2...

Well, since precision limits at X number of digits (depending on SINGLE, DOUBLE, _FLOAT), even then the answer would be doable with enough binary guesses.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Guess Number
« Reply #8 on: June 22, 2021, 03:05:25 pm »
Answers to 2 past answers: logarithm

=LOG(10^9;2)
=30 steps

what I write at once: numbers are cyclopean
and number of steps is logarithmic

Logarithm: those who understand think faster

My express lecture over 5 years ago from 2010++ years about...

Logarithm of Life

annually something changes in multiple

? through what QUANTITY of years is
something will give growth in right scale ?

SCALE is: GROWTH to extent of QUANTITY

SCALE = GROWTH ^ QUANTITY

QUANTITY: to what extent do you build
GROWTH to get SCALE

LOGARIFM: to what extent to erect
GROWTH to get SCALE

excel formula: QUANTITY = ...

=LOG(SCALE;GROWTH)

check: something annually grows 2 times

? in how many years
something will grow 64 times ?

SCALE = GROWTH ^ YEARS
64 = 2 ^ YEARS
YEAR = LOG(SCALE;GROWTH)
= LOG(64;2)
= 6
answer: over 6 years

example: over 25 years of inflation
devalued money 12 times

? what was inflation every year ?
? what was logarithm of inflation ?

? what should be growth to something
would have grown 12 times over 25 years ?

YEAR = LOG (SCALE;GROWTH)
GROWTH = SCALE ^ (1 / YEARS)

GROWTH = 12 ^ (1/25)
GROWTH = 1.1045 = 10.5 % per year

translate to same logarithm:
decimal: = LOG (SCALE) / LOG (GROWTH)
natural: = LN (SCALE) / LN (GROWTH)

 
ch64.png
« Last Edit: July 18, 2021, 12:42:59 pm by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Guess Number
« Reply #9 on: July 18, 2021, 12:46:24 pm »
Formula include Logarithm is checked through Math package

 
mathinfl.png


Example: if multiplier is 12 for 15 years: inflation =12^(1/15) = +18%.
Example: if multiplier is 12 and inflation is 1.18: =LOG(12)/LOG(1.18) = 15 years.


So I'm interested in: do you use WolframAlpha ?

 
wolflncp.png


In general a dozen formulas have been tested...

« Last Edit: July 18, 2021, 12:50:02 pm by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: Guess Number
« Reply #10 on: July 19, 2021, 03:46:46 am »

In general a dozen formulas have been tested...

is there a document confirming this formula?

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Guess Number
« Reply #11 on: July 19, 2021, 06:34:22 am »
formula is proved logically purely from definition of logarithm:
to what degree to raise to get
and I first solved it in numbers
and then understanding was translated into chains of formulas

https://wolframalpha.com/input/?i=solve+C%2B%281-p%29%5EN%3D1+for+N

https://mathsolver.microsoft.com/ru/solve-problem/C+%7B%60left(1-P%60right)%7D%5E%7BN%7D%3D1

plus formulas of compound percentage
are also derived logarithmically with checks

Visual Mathematics & DANILIN Russians formulas

500 KB = 0,5 MB

Russia & USA
http://kenokeno.ucoz.ru/doc/davizmath.pdf

Only english USA
http://kenokeno.ucoz.ru/doc/davizeng.pdf
« Last Edit: July 19, 2021, 07:20:15 am by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: Guess Number
« Reply #12 on: July 19, 2021, 07:43:43 am »
I was looking for something more official, but I found it!
dafips611555.jpg
* dafips611555.jpg (Filesize: 190.34 KB, Dimensions: 1024x800, Views: 307)

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Guess Number
« Reply #13 on: July 19, 2021, 11:01:54 am »
This forum included topic of 2019-2020 No. 1976:
approximately "Randomness and probability waves and we"
I do not remember exact name

Where we discussed with several ones even after analyzing and understanding formulas
but then topic went to off-topic and into archive and disappeared
and I can't find copies anywhere but my messages are same everywhere
and only answers of local ones are practically lost

Parallel english topic:
https://csharpforums.net/threads/falsification-of-probability.5109/page-2#post-15349

Internet Visual Mathematica

 
da_n_ln1c_ln1p.png



« Last Edit: July 20, 2021, 11:21:40 pm by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself