Author Topic: help my  (Read 19294 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: help my
« Reply #135 on: July 20, 2020, 05:59:20 pm »
Ciao Kiara87

riguardo al lotto ho fatto tempo fa in Excel un programmino che calcolava la somma a compenso.
Ossia calcoliamo quanto capitale devi investire per ottenere una vincita sicura.
Il caso più semplice è di giocare 2 numeri su singola ruota puntando 1 euro sulla ambata e 1 euro sull'ambo. Ora sviluppando le statistiche di probabilità di uscita sono 1 caso /90 * 89  ossia 1/8010 eventi. Ogni volta che non vinci ripeti la giocata aumentando la posta in modo da compensare con la vincita i soldi già spesi per giocare. Ebbene secondo lo schema di vincite del lotto https://www.estrazionedellotto.it/prontuario-vincite-lotto con ciascun ambata guadagni 5 euro e con l'ambo 250 euro. La giocata è realizzata quando fai ambo e quindi di conseguenza anche 2 ambate quindi la vincita sarebbe 260 euro circa puntando 1 euro su ambata e 1 euro su ambo e giocando 2 numeri su una sola ruota di estrazione. Essendo la probailità dell'evento 1 su 8010 considerando anche la peggiore sfortuna devi arrivare a giocare 8010 volte quei 2 numeri per vincere sicuri. La prima volta punti 2 euro e così continui fino a 260 euro (ossia le prime 130 puntate) poi devi iniziare a incrementare la puntata per recuperare i soldi spesi nelle precedenti puntate. Se lo trovo te lo posto, permette di avere una prospettiva chiara delle somme necessarie per vincere sicuri al lotto.
Un mio amico amava molto giocare al lotto, quindi ne parlava spesso e vista la mia propensione alla programmazione mi chiese di provare a fare un programma che gli permettesse di fare i calcoli per scegliere le giocate vincenti. Aritmologia pura. Sai bene che in Aritmologia i numeri sono circolari come fai tu con il lotto 1- 90 = 1 in Aritmologia a base 90 mentre in Aritmetica 1-90 = -89 a base decimale, 24 +70 = 4 in Aritmologia a base 90 mentre in aritmetica 24+70 = 94 a base decimale.
Una volta definito il problema lo puoi riprodurre e gestire con il codice programma.
Nell'esempio dell'AMBO ISOTOPI che mi hai fatto per spiegarmi la distanza diagonale la differenza tra 72 e 84 in Aritmetica è -12 mentre in Aritmologia 72-84=78. Allo stesso modo la distanza tra 24 e 84 ossia 24-84= 30  in Aritmologia mentre in Aritmetica 24-84 = -60!
Questo piccolo concetto spero che tu lo abbia passato a Bplus ossia che i calcoli vanno fatti secondo l'Aritmologia e non la matematica.
Hai ritenuto molti concetti come se fossero noti a tutti ma sono specifici degli appassionati del lotto.


English version by Google
Hi Kiara87

regarding the lot, I made a program in Excel some time ago that calculated the sum in compensation.
That is, we calculate how much capital you have to invest to get a safe win.
The simplest case is to play 2 numbers on a single wheel by betting 1 euro on the ambata and 1 euro on the both. Now developing the exit probability statistics are 1 case / 90 * 89 or 1/8010 events. Every time you don't win, repeat the game by increasing the stakes in order to compensate with the winnings the money already spent to play. Well according to the winnings scheme of the lot [url] https://www.estrazionedellotto.it/prontuario-vincite-lotto [/ url] with each ambate you earn 5 euros and with the both 250 euros. The bet is made when you do both and consequently also 2 ambates so the win would be around 260 euros by betting 1 euro on ambata and 1 euro on both and playing 2 numbers on a single extraction wheel. Being the probability of event 1 out of 8010 considering even the worst of bad luck you have to get to play 8010 times those 2 numbers to win safely. The first time you bet 2 euros and so you continue up to 260 euros (i.e. the first 130 bets) then you have to start increasing the bet to recover the money spent in the previous bets. If I find it, I place it, it allows you to have a clear perspective of the sums necessary to win the lot safely.
A friend of mine loved playing lotto, so he often talked about it and given my propensity for programming he asked me to try to make a program that would allow him to do the calculations to choose the winning games. Pure arrhythmology. You know well that in Arithmology the numbers are circular as you do with the lot 1- 90 = 1 in Arithmology with base 90 while in Arithmetic 1-90 = -89 with decimal basis, 24 +70 = 4 in Arithmology with base 90 while in arithmetic 24 + 70 = 94 with a decimal base.
Once the problem is defined you can reproduce it and manage it with the program code.
In the example of the AMBO ISOTOPES you made to explain the diagonal distance the difference between 72 and 84 in Arithmetic is -12 while in Arithmology 72-84 = 78. In the same way the distance between 24 and 84 or 24-84 = 30 in Arithmology while in Arithmetic 24-84 = -60!
I hope that you have passed this small concept to Bplus, that is, that the calculations must be made according to Arithmology and not mathematics.
You have thought many ideas as known by all but these concepts are specific for those loves lotto game.
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: help my
« Reply #136 on: July 20, 2020, 06:17:09 pm »
"Arithmology" 

Code: QB64: [Select]
  1. FUNCTION missingTriple (t1, t2)
  2.     DIM first, second, third
  3.     IF t1 < 31 THEN
  4.         first = t1
  5.     ELSEIF t1 < 61 THEN
  6.         second = t1
  7.     ELSE
  8.         third = t1
  9.     END IF
  10.     IF t2 < 31 THEN
  11.         first = t2
  12.     ELSEIF t2 < 61 THEN
  13.         second = t2
  14.     ELSE
  15.         third = t2
  16.     END IF
  17.     IF first = 0 THEN
  18.         missingTriple = second - 30
  19.     ELSEIF second = 0 THEN
  20.         missingTriple = third - 30
  21.     ELSE
  22.         missingTriple = second + 30
  23.     END IF
  24.  


True or False is the pair part of a triple?
Code: QB64: [Select]
  1. FUNCTION diff30in90 (a, b) 'default integers a-z
  2.     DIM hi, lo
  3.     IF a > 90 OR b > 90 OR a < 1 OR b < 1 OR a = b THEN EXIT FUNCTION 'no diff return 0
  4.     IF a > b THEN hi = a: lo = b ELSE hi = b: lo = a
  5.     IF hi - lo = 30 THEN
  6.         diff30in90 = -1
  7.     ELSE
  8.         IF ABS(hi - lo) = 60 THEN diff30in90 = -1
  9.     END IF
  10.  
« Last Edit: July 20, 2020, 06:22:29 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: help my
« Reply #138 on: July 23, 2020, 04:37:47 pm »
@Kiara87

Here it is, I couldn't leave it alone. I knew there wasn't enough room to print all the pairs of Triples in the middle screen with labels so I did an short version.

Complete make over almost!
Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's      b+ 2020-07-23 makeover old kiara help code
  2. _TITLE "Lotto Data Triples" '     new title it's all about the triples!
  3. SCREEN _NEWIMAGE(640, 400, 32) '  need graphics screen for all the new colors!
  4. _DELAY .25 'while screen loads
  5.  
  6. '2020-07-17 remove weekday names, move labels into there, fix bottom line up/down click
  7. '           fix function convertLottoNum2Date$ spelling
  8. '           clean out some redundant code loops
  9. ' 2020-07-18 change GOSUB loadLineDAT_Mark30s:
  10. '           to mark Blue only line with triple pairs. Can only do one pair at time for right screen check.
  11. '           Make function missingTriple, so we know what number to search for on right screen.
  12. '           OK modified loadLineDAT_Mark30s: GOSUB some more to catch the missing triple pair
  13. '           marked in Red on right screen.
  14. '
  15. '                               * * * A whole different approach! * * *
  16. ' 2020-07-23 OK look for triple pairs in left screen to complete in the right screen.
  17. '                        ALL NUMBERS ARE COLOR CODED IN LEFT SCREEN
  18. '           The most triples possible is 30, in fact lets keep an array to track which triple
  19. '           each data item on left screen is a member of. The we will analyze the 30 triples for
  20. '           Singles, Pairs and Complete Triples.
  21. '           We will feed a sub 2 data strings from the file and it will match up the missing triples in right screen.
  22. '            create showLottoLines - takes 2 lotto lines and creates array with all triples sorted into locations,
  23. '                                    and display screens while we data in hand.
  24. '            create whichTriple - takes a lotto number in string form and assigns a base30 number and level 1 to 3
  25. '            create makePal - makes a palette of 30 distinct colors I hope
  26. '            convert labelscreen to sub.
  27. '            Looks marvelous to me!
  28.  
  29. DEFINT A-Z ' everything is integer unless DIM or suffix
  30. CONST nRows = 11 '                          rows of 5 data points in each line of fileDat
  31. DIM SHARED shiftRight, shiftRight2 '        screening data left and right, normally these would be CONSTANTs
  32. shiftRight = 11 '                           according to screen fit
  33. shiftRight2 = 65 '                          according to screen fit
  34.  
  35. DIM count '                                 for number of lines in the data file
  36.  
  37. DIM lineNum, lineNum2 '                     for tracking array access this is actual file line of data we are screening
  38. DIM a AS STRING '                           file line of data
  39.  
  40. ' user inputs
  41. DIM Q$ '                                    for INKEY$
  42. DIM mb, mx, my, oldmouse '                  Mouse stuff oldmouse is trick Steve McNeill showed us to get ONE mouse click!
  43.  
  44. DIM i '                                     common use for indexing
  45.  
  46. DIM SHARED msNomeMesi(1 TO 12) AS STRING ' matrice di stringhe
  47. msNomeMesi(1) = "Gennaio"
  48. msNomeMesi(2) = "Febbraio"
  49. msNomeMesi(3) = "Marzo"
  50. msNomeMesi(4) = "Aprile"
  51. msNomeMesi(5) = "Maggio"
  52. msNomeMesi(6) = "Giugno"
  53. msNomeMesi(7) = "Luglio"
  54. msNomeMesi(8) = "Agosto"
  55. msNomeMesi(9) = "Settembre"
  56. msNomeMesi(10) = "Ottobre"
  57. msNomeMesi(11) = "Novembre"
  58. msNomeMesi(12) = "Dicembre"
  59.  
  60. DIM SHARED labels(1 TO 11) AS STRING ' setup screen labels for reporting data
  61. labels(1) = "BARI"
  62. labels(2) = "CAGLIARI"
  63. labels(3) = "FIRENZE"
  64. labels(4) = "GENOVA"
  65. labels(5) = "MILANO"
  66. labels(6) = "NAPOLI"
  67. labels(7) = "PALERMO"
  68. labels(8) = "ROMA"
  69. labels(9) = "TORINO"
  70. labels(10) = "VENEZIA"
  71. labels(11) = "NAZIONALE"
  72.  
  73. '-------------------------------- start Main setup get file data loaded into array
  74.  
  75. DIM SHARED pal(1 TO 30) AS _UNSIGNED LONG ' colors  for the 30 different triples
  76. makePal 'load up palette
  77.  
  78. 'count lines in file
  79. OPEN "lotto.dat" FOR INPUT AS #1
  80.     INPUT #1, a
  81.     '          debug check inputs from file
  82.     'PRINT a
  83.     'INPUT " OK enter "; w$
  84.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  85.  
  86. 'now we know size of file so ready an array to load file Data
  87. DIM fileDAT(1 TO count) AS STRING
  88. OPEN "lotto.dat" FOR INPUT AS #1
  89. FOR i = 1 TO count
  90.     INPUT #1, a
  91.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  92.  
  93. 'get/set first line and get a data string from the FileDAT array  (left set on screen)
  94. lineNum = 1 'left screen data line
  95. lineNum2 = 1 'right screen data line
  96.  
  97. DO '------------------------------------------------ Main Loop User selects data to compare
  98.     CLS
  99.     Q$ = INKEY$
  100.     IF Q$ = "+" THEN lineNum = lineNum + 1
  101.     IF Q$ = "-" THEN lineNum = lineNum - 1
  102.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  103.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  104.  
  105.     mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  106.     IF mb AND oldmouse = 0 AND my > 24 THEN ' <<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  107.         IF 3 * 8 <= mx AND mx <= 11 * 8 THEN lineNum = lineNum + 1
  108.         IF 14 * 8 <= mx AND mx <= 23 * 8 THEN lineNum = lineNum - 1
  109.         IF 56 * 8 <= mx AND mx <= 64 * 8 THEN lineNum2 = lineNum2 + 1
  110.         IF 67 * 8 <= mx AND mx <= 76 * 8 THEN lineNum2 = lineNum2 - 1
  111.     END IF
  112.     oldmouse = _MOUSEBUTTON(1) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  113.     IF lineNum > count THEN lineNum = 1
  114.     IF lineNum < 1 THEN lineNum = count
  115.     IF lineNum2 > count THEN lineNum2 = 1
  116.     IF lineNum2 < 1 THEN lineNum2 = count
  117.     labelScreen
  118.     showLottoLines fileDAT(lineNum), fileDAT(lineNum2) 'print out the data from the new line
  119.     _DISPLAY
  120.     _LIMIT 30
  121.  
  122. SUB labelScreen
  123.     DIM i
  124.     COLOR &HFFFFFFFF
  125.     FOR i = 1 TO 11
  126.         LOCATE i * 2 + 1, 1: PRINT labels(i)
  127.         LOCATE i * 2 + 1, 55: PRINT labels(i)
  128.     NEXT
  129.     LOCATE 25, 1
  130.     PRINT "  Fino / Up  Giu / Down        : Fare clic su :        Fino / Up  Giu / Down";
  131.     '      12345678901234567890123456789012345678901234567890123456789012345678901234567890
  132.     '               1         2         3         4         5         6         7         8
  133.  
  134. SUB makePal 'make 30 distinctive colors I hope
  135.     DIM i, m, q
  136.     q = 40
  137.     FOR i = 1 TO 30
  138.         m = INT(i / 7) + 1
  139.         SELECT CASE i MOD 7
  140.             CASE 0: pal(i) = _RGB32(m * q + 55, 50, 50)
  141.             CASE 1: pal(i) = _RGB32(50, m * q + 55, 50)
  142.             CASE 2: pal(i) = _RGB32(50, 0, m * q + 55)
  143.             CASE 3: pal(i) = _RGB32(m * q + 55, m * q + 55, 50)
  144.             CASE 4: pal(i) = _RGB32(m * q + 55, 50, m * q + 55)
  145.             CASE 5: pal(i) = _RGB32(50, m * q + 55, m * q + 55)
  146.             CASE 6: pal(i) = _RGB32(m * q + 55, .5 * m * q + 55, .25 * m * q + 55)
  147.         END SELECT
  148.     NEXT
  149.  
  150. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  151.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  152.  
  153. SUB showLottoLines (LottoLine$, LottoLine2$)
  154.     DIM sortedData(1 TO 30, 1 TO 3) AS STRING 'each data line c
  155.     DIM i, d$, b, l, lottoNum, lottoDate$, row, col, count, j, printline, s$, missingT, aplace
  156.  
  157.     COLOR &HFFFFFFFF ' start with white and print dates
  158.     lottoNum = VAL(LEFT$(LottoLine$, 4))
  159.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  160.     LOCATE 1, 1: PRINT lottoDate$;
  161.     lottoNum = VAL(LEFT$(LottoLine2$, 4))
  162.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  163.     LOCATE 1, 48: PRINT lottoDate$;
  164.  
  165.     FOR i = 1 TO 55 'print right screen = lottoLine2$
  166.         row = INT((i - 1) / 5) + 1
  167.         col = (i - 1) MOD 5 + 1
  168.         d$ = MID$(LottoLine2$, i * 2 + 3, 2)
  169.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT d$; ' Left side
  170.     NEXT
  171.  
  172.     FOR i = 1 TO 55 'print left screen  all the 11 X 5 double digit data and collect data locations of triples
  173.         row = INT((i - 1) / 5) + 1
  174.         col = (i - 1) MOD 5 + 1
  175.         d$ = MID$(LottoLine$, i * 2 + 3, 2)
  176.         whichTriple d$, b, l
  177.         sortedData(b, l) = sortedData(b, l) + DD$(i) 'creating a string of Double Digit (DD$) data locations
  178.         COLOR pal(b)
  179.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT d$; ' Left side
  180.     NEXT
  181.  
  182.     printline = 3 ' to 24
  183.     COLOR &HFFFFFFFF
  184.     FOR i = 1 TO 30 ' going through all the base triples numbers <=30
  185.         COLOR pal(i)
  186.         count = 0
  187.         FOR j = 1 TO 3
  188.             IF sortedData(i, j) <> "" THEN count = count + 1
  189.         NEXT
  190.         IF count = 2 THEN ' found a pair missing a triple
  191.             s$ = ""
  192.             FOR j = 1 TO 3
  193.                 d$ = sortedData(i, j)
  194.                 IF d$ = "" THEN ' look for the missing triple in the right side of screen
  195.                     d$ = "XX"
  196.                     missingT = i + (j - 1) * (30)
  197.                     'scan the right data for missingT
  198.                     aplace = 5
  199.                     FOR row = 1 TO 11 'mark the missing triples with triple color
  200.                         FOR col = 1 TO 5
  201.                             IF VAL(MID$(LottoLine2$, aplace, 2)) = missingT THEN
  202.                                 LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT MID$(LottoLine2$, aplace, 2); '<< a2 now Right Side
  203.                             END IF
  204.                             aplace = aplace + 2
  205.                         NEXT
  206.                     NEXT
  207.                 END IF
  208.                 s$ = s$ + " " + _TRIM$(STR$(i + (j - 1) * 30)) + ":" + d$
  209.             NEXT
  210.             LOCATE printline, 28: PRINT s$
  211.             printline = printline + 1
  212.             IF printline = 25 THEN LOCATE printline, 28: PRINT "out of room!";: EXIT FOR
  213.         END IF
  214.     NEXT
  215.  
  216. SUB whichTriple (number1To90$, base30, level30) 'return a number 1 to 30 and a level 1 to 3  for 2 digit loot number
  217.     DIM n AS INTEGER
  218.     n = VAL(number1To90$)
  219.     IF n > 90 OR n < 1 THEN base30 = 0: level30 = 0: BEEP: EXIT SUB 'alert we have bad number
  220.     IF n <= 30 THEN
  221.         base30 = n: level30 = 1
  222.     ELSEIF n <= 60 THEN
  223.         base30 = n - 30: level30 = 2
  224.     ELSEIF n <= 90 THEN
  225.         base30 = n - 60: level30 = 3
  226.     END IF
  227.  
  228. ' -----------------------------------------------------  Convert Lotto Num to Date Function and helpers
  229. FUNCTION ConvertLottoNumToDate$ (lottoNumX)
  230.     DIM numberOfDays1463, yr, mo
  231.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  232.     yr = 2017
  233.     mo = 6
  234.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  235.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  236.         mo = mo + 1
  237.         IF mo = 13 THEN mo = 1: yr = yr + 1
  238.     WEND
  239.     ' date shound be day name date/month/year for Italians
  240.     ConvertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  241.  
  242. FUNCTION lottoday$ (lottoNum)
  243.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  244.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  245.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  246.  
  247. FUNCTION daysInMonth% (mNum, yearNum)
  248.     DIM copyM, copyY
  249.     copyM = mNum
  250.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  251.     SELECT CASE copyM
  252.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  253.         CASE 4, 6, 9, 11: daysInMonth% = 30
  254.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  255.     END SELECT
  256.  
  257. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  258.     DIM days AS INTEGER
  259.     IF yr MOD 4 = 0 THEN
  260.         IF yr MOD 100 = 0 THEN
  261.             IF yr MOD 400 = 0 THEN days = 29
  262.         ELSE
  263.             days = 29
  264.         END IF
  265.     END IF
  266.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  267.  

  [ You are not allowed to view this attachment ]  

You can see the completed triple stand out 19, 49, 79 on the first screen.
« Last Edit: July 23, 2020, 04:40:43 pm by bplus »

Offline Kiara87

  • Forum Regular
  • Posts: 164
Re: help my
« Reply #139 on: July 24, 2020, 02:43:23 am »
@Kiara87

Here it is, I couldn't leave it alone. I knew there wasn't enough room to print all the pairs of Triples in the middle screen with labels so I did an short version.

Complete make over almost!
Code: QB64: [Select]
  1. OPTION _EXPLICIT 'for typo's      b+ 2020-07-23 makeover old kiara help code
  2. _TITLE "Lotto Data Triples" '     new title it's all about the triples!
  3. SCREEN _NEWIMAGE(640, 400, 32) '  need graphics screen for all the new colors!
  4. _DELAY .25 'while screen loads
  5.  
  6. '2020-07-17 remove weekday names, move labels into there, fix bottom line up/down click
  7. '           fix function convertLottoNum2Date$ spelling
  8. '           clean out some redundant code loops
  9. ' 2020-07-18 change GOSUB loadLineDAT_Mark30s:
  10. '           to mark Blue only line with triple pairs. Can only do one pair at time for right screen check.
  11. '           Make function missingTriple, so we know what number to search for on right screen.
  12. '           OK modified loadLineDAT_Mark30s: GOSUB some more to catch the missing triple pair
  13. '           marked in Red on right screen.
  14. '
  15. '                               * * * A whole different approach! * * *
  16. ' 2020-07-23 OK look for triple pairs in left screen to complete in the right screen.
  17. '                        ALL NUMBERS ARE COLOR CODED IN LEFT SCREEN
  18. '           The most triples possible is 30, in fact lets keep an array to track which triple
  19. '           each data item on left screen is a member of. The we will analyze the 30 triples for
  20. '           Singles, Pairs and Complete Triples.
  21. '           We will feed a sub 2 data strings from the file and it will match up the missing triples in right screen.
  22. '            create showLottoLines - takes 2 lotto lines and creates array with all triples sorted into locations,
  23. '                                    and display screens while we data in hand.
  24. '            create whichTriple - takes a lotto number in string form and assigns a base30 number and level 1 to 3
  25. '            create makePal - makes a palette of 30 distinct colors I hope
  26. '            convert labelscreen to sub.
  27. '            Looks marvelous to me!
  28.  
  29. DEFINT A-Z ' everything is integer unless DIM or suffix
  30. CONST nRows = 11 '                          rows of 5 data points in each line of fileDat
  31. DIM SHARED shiftRight, shiftRight2 '        screening data left and right, normally these would be CONSTANTs
  32. shiftRight = 11 '                           according to screen fit
  33. shiftRight2 = 65 '                          according to screen fit
  34.  
  35. DIM count '                                 for number of lines in the data file
  36.  
  37. DIM lineNum, lineNum2 '                     for tracking array access this is actual file line of data we are screening
  38. DIM a AS STRING '                           file line of data
  39.  
  40. ' user inputs
  41. DIM Q$ '                                    for INKEY$
  42. DIM mb, mx, my, oldmouse '                  Mouse stuff oldmouse is trick Steve McNeill showed us to get ONE mouse click!
  43.  
  44. DIM i '                                     common use for indexing
  45.  
  46. DIM SHARED msNomeMesi(1 TO 12) AS STRING ' matrice di stringhe
  47. msNomeMesi(1) = "Gennaio"
  48. msNomeMesi(2) = "Febbraio"
  49. msNomeMesi(3) = "Marzo"
  50. msNomeMesi(4) = "Aprile"
  51. msNomeMesi(5) = "Maggio"
  52. msNomeMesi(6) = "Giugno"
  53. msNomeMesi(7) = "Luglio"
  54. msNomeMesi(8) = "Agosto"
  55. msNomeMesi(9) = "Settembre"
  56. msNomeMesi(10) = "Ottobre"
  57. msNomeMesi(11) = "Novembre"
  58. msNomeMesi(12) = "Dicembre"
  59.  
  60. DIM SHARED labels(1 TO 11) AS STRING ' setup screen labels for reporting data
  61. labels(1) = "BARI"
  62. labels(2) = "CAGLIARI"
  63. labels(3) = "FIRENZE"
  64. labels(4) = "GENOVA"
  65. labels(5) = "MILANO"
  66. labels(6) = "NAPOLI"
  67. labels(7) = "PALERMO"
  68. labels(8) = "ROMA"
  69. labels(9) = "TORINO"
  70. labels(10) = "VENEZIA"
  71. labels(11) = "NAZIONALE"
  72.  
  73. '-------------------------------- start Main setup get file data loaded into array
  74.  
  75. DIM SHARED pal(1 TO 30) AS _UNSIGNED LONG ' colors  for the 30 different triples
  76. makePal 'load up palette
  77.  
  78. 'count lines in file
  79. OPEN "lotto.dat" FOR INPUT AS #1
  80.     INPUT #1, a
  81.     '          debug check inputs from file
  82.     'PRINT a
  83.     'INPUT " OK enter "; w$
  84.     IF LEN(_TRIM$(a)) THEN count = count + 1 'don't want empty lines _TRIM$ removes spaces or other nonsense
  85.  
  86. 'now we know size of file so ready an array to load file Data
  87. DIM fileDAT(1 TO count) AS STRING
  88. OPEN "lotto.dat" FOR INPUT AS #1
  89. FOR i = 1 TO count
  90.     INPUT #1, a
  91.     IF LEN(_TRIM$(a)) THEN fileDAT(i) = a 'don't want empty lines _TRIM$ removes spaces or other nonsense
  92.  
  93. 'get/set first line and get a data string from the FileDAT array  (left set on screen)
  94. lineNum = 1 'left screen data line
  95. lineNum2 = 1 'right screen data line
  96.  
  97. DO '------------------------------------------------ Main Loop User selects data to compare
  98.     CLS
  99.     Q$ = INKEY$
  100.     IF Q$ = "+" THEN lineNum = lineNum + 1
  101.     IF Q$ = "-" THEN lineNum = lineNum - 1
  102.     IF Q$ = CHR$(0) + CHR$(72) THEN lineNum2 = lineNum2 + 1
  103.     IF Q$ = CHR$(0) + CHR$(80) THEN lineNum2 = lineNum2 - 1
  104.  
  105.     mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  106.     IF mb AND oldmouse = 0 AND my > 24 THEN ' <<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  107.         IF 3 * 8 <= mx AND mx <= 11 * 8 THEN lineNum = lineNum + 1
  108.         IF 14 * 8 <= mx AND mx <= 23 * 8 THEN lineNum = lineNum - 1
  109.         IF 56 * 8 <= mx AND mx <= 64 * 8 THEN lineNum2 = lineNum2 + 1
  110.         IF 67 * 8 <= mx AND mx <= 76 * 8 THEN lineNum2 = lineNum2 - 1
  111.     END IF
  112.     oldmouse = _MOUSEBUTTON(1) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<   THANK's  SMcNeill
  113.     IF lineNum > count THEN lineNum = 1
  114.     IF lineNum < 1 THEN lineNum = count
  115.     IF lineNum2 > count THEN lineNum2 = 1
  116.     IF lineNum2 < 1 THEN lineNum2 = count
  117.     labelScreen
  118.     showLottoLines fileDAT(lineNum), fileDAT(lineNum2) 'print out the data from the new line
  119.     _DISPLAY
  120.     _LIMIT 30
  121.  
  122. SUB labelScreen
  123.     DIM i
  124.     COLOR &HFFFFFFFF
  125.     FOR i = 1 TO 11
  126.         LOCATE i * 2 + 1, 1: PRINT labels(i)
  127.         LOCATE i * 2 + 1, 55: PRINT labels(i)
  128.     NEXT
  129.     LOCATE 25, 1
  130.     PRINT "  Fino / Up  Giu / Down        : Fare clic su :        Fino / Up  Giu / Down";
  131.     '      12345678901234567890123456789012345678901234567890123456789012345678901234567890
  132.     '               1         2         3         4         5         6         7         8
  133.  
  134. SUB makePal 'make 30 distinctive colors I hope
  135.     DIM i, m, q
  136.     q = 40
  137.     FOR i = 1 TO 30
  138.         m = INT(i / 7) + 1
  139.         SELECT CASE i MOD 7
  140.             CASE 0: pal(i) = _RGB32(m * q + 55, 50, 50)
  141.             CASE 1: pal(i) = _RGB32(50, m * q + 55, 50)
  142.             CASE 2: pal(i) = _RGB32(50, 0, m * q + 55)
  143.             CASE 3: pal(i) = _RGB32(m * q + 55, m * q + 55, 50)
  144.             CASE 4: pal(i) = _RGB32(m * q + 55, 50, m * q + 55)
  145.             CASE 5: pal(i) = _RGB32(50, m * q + 55, m * q + 55)
  146.             CASE 6: pal(i) = _RGB32(m * q + 55, .5 * m * q + 55, .25 * m * q + 55)
  147.         END SELECT
  148.     NEXT
  149.  
  150. FUNCTION DD$ (number) 'convert a number into a 2 digit string$
  151.     DD$ = RIGHT$("00" + _TRIM$(STR$(number)), 2)
  152.  
  153. SUB showLottoLines (LottoLine$, LottoLine2$)
  154.     DIM sortedData(1 TO 30, 1 TO 3) AS STRING 'each data line c
  155.     DIM i, d$, b, l, lottoNum, lottoDate$, row, col, count, j, printline, s$, missingT, aplace
  156.  
  157.     COLOR &HFFFFFFFF ' start with white and print dates
  158.     lottoNum = VAL(LEFT$(LottoLine$, 4))
  159.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  160.     LOCATE 1, 1: PRINT lottoDate$;
  161.     lottoNum = VAL(LEFT$(LottoLine2$, 4))
  162.     lottoDate$ = ConvertLottoNumToDate$(lottoNum)
  163.     LOCATE 1, 48: PRINT lottoDate$;
  164.  
  165.     FOR i = 1 TO 55 'print right screen = lottoLine2$
  166.         row = INT((i - 1) / 5) + 1
  167.         col = (i - 1) MOD 5 + 1
  168.         d$ = MID$(LottoLine2$, i * 2 + 3, 2)
  169.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT d$; ' Left side
  170.     NEXT
  171.  
  172.     FOR i = 1 TO 55 'print left screen  all the 11 X 5 double digit data and collect data locations of triples
  173.         row = INT((i - 1) / 5) + 1
  174.         col = (i - 1) MOD 5 + 1
  175.         d$ = MID$(LottoLine$, i * 2 + 3, 2)
  176.         whichTriple d$, b, l
  177.         sortedData(b, l) = sortedData(b, l) + DD$(i) 'creating a string of Double Digit (DD$) data locations
  178.         COLOR pal(b)
  179.         LOCATE row * 2 + 1, col * 3 - 2 + shiftRight: PRINT d$; ' Left side
  180.     NEXT
  181.  
  182.     printline = 3 ' to 24
  183.     COLOR &HFFFFFFFF
  184.     FOR i = 1 TO 30 ' going through all the base triples numbers <=30
  185.         COLOR pal(i)
  186.         count = 0
  187.         FOR j = 1 TO 3
  188.             IF sortedData(i, j) <> "" THEN count = count + 1
  189.         NEXT
  190.         IF count = 2 THEN ' found a pair missing a triple
  191.             s$ = ""
  192.             FOR j = 1 TO 3
  193.                 d$ = sortedData(i, j)
  194.                 IF d$ = "" THEN ' look for the missing triple in the right side of screen
  195.                     d$ = "XX"
  196.                     missingT = i + (j - 1) * (30)
  197.                     'scan the right data for missingT
  198.                     aplace = 5
  199.                     FOR row = 1 TO 11 'mark the missing triples with triple color
  200.                         FOR col = 1 TO 5
  201.                             IF VAL(MID$(LottoLine2$, aplace, 2)) = missingT THEN
  202.                                 LOCATE row * 2 + 1, col * 3 - 2 + shiftRight2: PRINT MID$(LottoLine2$, aplace, 2); '<< a2 now Right Side
  203.                             END IF
  204.                             aplace = aplace + 2
  205.                         NEXT
  206.                     NEXT
  207.                 END IF
  208.                 s$ = s$ + " " + _TRIM$(STR$(i + (j - 1) * 30)) + ":" + d$
  209.             NEXT
  210.             LOCATE printline, 28: PRINT s$
  211.             printline = printline + 1
  212.             IF printline = 25 THEN LOCATE printline, 28: PRINT "out of room!";: EXIT FOR
  213.         END IF
  214.     NEXT
  215.  
  216. SUB whichTriple (number1To90$, base30, level30) 'return a number 1 to 30 and a level 1 to 3  for 2 digit loot number
  217.     DIM n AS INTEGER
  218.     n = VAL(number1To90$)
  219.     IF n > 90 OR n < 1 THEN base30 = 0: level30 = 0: BEEP: EXIT SUB 'alert we have bad number
  220.     IF n <= 30 THEN
  221.         base30 = n: level30 = 1
  222.     ELSEIF n <= 60 THEN
  223.         base30 = n - 30: level30 = 2
  224.     ELSEIF n <= 90 THEN
  225.         base30 = n - 60: level30 = 3
  226.     END IF
  227.  
  228. ' -----------------------------------------------------  Convert Lotto Num to Date Function and helpers
  229. FUNCTION ConvertLottoNumToDate$ (lottoNumX)
  230.     DIM numberOfDays1463, yr, mo
  231.     numberOfDays1463 = INT(lottoNumX - 1463) / 3 * 7
  232.     yr = 2017
  233.     mo = 6
  234.     WHILE numberOfDays1463 > daysInMonth%(mo, yr) - 1
  235.         numberOfDays1463 = numberOfDays1463 - daysInMonth%(mo, yr)
  236.         mo = mo + 1
  237.         IF mo = 13 THEN mo = 1: yr = yr + 1
  238.     WEND
  239.     ' date shound be day name date/month/year for Italians
  240.     ConvertLottoNumToDate$ = lottoday$(lottoNumX) + _TRIM$(STR$(numberOfDays1463 + 1)) + "/" + msNomeMesi(mo) + "/" + _TRIM$(STR$(yr))
  241.  
  242. FUNCTION lottoday$ (lottoNum)
  243.     IF lottoNum MOD 3 = 1 THEN lottoday$ = "Martedi, "
  244.     IF lottoNum MOD 3 = 2 THEN lottoday$ = "Giovedi, "
  245.     IF lottoNum MOD 3 = 0 THEN lottoday$ = "Sabato, "
  246.  
  247. FUNCTION daysInMonth% (mNum, yearNum)
  248.     DIM copyM, copyY
  249.     copyM = mNum
  250.     IF mNum = 13 THEN copyM = 1: copyY = yearNum + 1 ELSE copyY = yearNum
  251.     SELECT CASE copyM
  252.         CASE 1, 3, 5, 7, 8, 10, 12: daysInMonth% = 31
  253.         CASE 4, 6, 9, 11: daysInMonth% = 30
  254.         CASE 2: daysInMonth% = daysInFeb%(copyY)
  255.     END SELECT
  256.  
  257. FUNCTION daysInFeb% (yr) 'from Pete's calendar this is a very clear calc
  258.     DIM days AS INTEGER
  259.     IF yr MOD 4 = 0 THEN
  260.         IF yr MOD 100 = 0 THEN
  261.             IF yr MOD 400 = 0 THEN days = 29
  262.         ELSE
  263.             days = 29
  264.         END IF
  265.     END IF
  266.     IF days THEN daysInFeb% = days ELSE daysInFeb% = 28
  267.  

  [ You are not allowed to view this attachment ]  

You can see the completed triple stand out 19, 49, 79 on the first screen.

thanks bplus
but this not only finds the distance 30 but finds all numbers
but a great job you are very good at programming
this will be useful when I learn
so I can edit it
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: help my
« Reply #140 on: July 24, 2020, 11:48:04 am »
Quote from: qb64
thanks bplus
but this not only finds the distance 30 but finds all numbers
but a great job you are very good at programming
this will be useful when I learn
so I can edit it

Listed in the middle are all the triple PAIRS missing the 3rd triple in the Left screen, the found 3rd triple is color coded on the right.

Isn't that what you wanted? (except the color coding, but that makes more clear which triple it is from.)

Oh also I listed the data location 1 to 55 instead of the Italian Label names for the rows (1 to 11) so you can locate exactly where the triple came from. Like I said there is NOT enough room to list all the Italian label names for the pairs. Could convert to row numbers with a conversion function.
« Last Edit: July 24, 2020, 02:18:23 pm by bplus »

Offline Kiara87

  • Forum Regular
  • Posts: 164
Re: help my
« Reply #141 on: July 24, 2020, 04:22:38 pm »
Listed in the middle are all the triple PAIRS missing the 3rd triple in the Left screen, the found 3rd triple is color coded on the right.

Isn't that what you wanted? (except the color coding, but that makes more clear which triple it is from.)

Oh also I listed the data location 1 to 55 instead of the Italian Label names for the rows (1 to 11) so you can locate exactly where the triple came from. Like I said there is NOT enough room to list all the Italian label names for the pairs. Could convert to row numbers with a conversion function.

thanks for your interest but I didn't mean this
what I meant not from too many numbers
for example in the extraction of 6 June 2017
from only two conditions

that are these

06/06/2017  CAGLIARI 37-34  (1°-2°)  Dist.Vert.30
06/06/2017  MILANO   07-64  (1°-2°)
Ambi ISOTOPI
-------------------------------------------
06/06/2017  NAPOLI   72-84  (2°-4°)  Dist.Diag.30
06/06/2017  VENEZIA 24-12  (2°-4°)
Ambi ISOTOPI
-------------------------------------------
in the other extractions it can give a maximum of 4 or 5 conditions not many conditions
but many times one or two conditions occur
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: help my
« Reply #142 on: July 25, 2020, 01:25:35 pm »
@Kiara87
riguardo a
Quote
for example in the extraction of 6 June 2017
from only two conditions

that are these

06/06/2017  CAGLIARI 37-34  (1°-2°)  Dist.Vert.30
06/06/2017  MILANO   07-64  (1°-2°)
Ambi ISOTOPI
-------------------------------------------
06/06/2017  NAPOLI   72-84  (2°-4°)  Dist.Diag.30
06/06/2017  VENEZIA 24-12  (2°-4°)
Ambi ISOTOPI

rilevati i 2 ambi isotopi con distanza 30  seguendo le regole aritmologiche 24-84= -60 +90 =30 distanza 30 diagonale, 12 - 72  = -60 +90 = 30 cosa altro deve fare il programma del lotto?
Programming isn't difficult, only it's  consuming time and coffee

Offline Kiara87

  • Forum Regular
  • Posts: 164
Re: help my
« Reply #143 on: July 25, 2020, 05:27:49 pm »
@Kiara87
riguardo a
rilevati i 2 ambi isotopi con distanza 30  seguendo le regole aritmologiche 24-84= -60 +90 =30 distanza 30 diagonale, 12 - 72  = -60 +90 = 30 cosa altro deve fare il programma del lotto?
aritmologiche  ma nel lotto si chiamano terzine simmetriche
il programma dalle condizioni che trova deve segnare nel mezzo delle due estrazioni
le condizioni che sono uscite con le terzine simmetriche mancanti come ha fatto bplus nel programma precedente
quello che rilevava solamente una sola condizione rilevava solo la condizione isotopa
io volevo aggiungere che mi rilevava anche le condizioni si isotope ma anche in verticale è orizzontali

il programma dovrebbe fare diamo esempio nella estrazione che ha messo bplus

06/06/2017  CAGLIARI 37-34  (1°-2°)  Dist.Vert.30
06/06/2017  MILANO   07-64  (1°-2°)
Ambi ISOTOPI
-------------------------------------------
06/06/2017  NAPOLI   72-84  (2°-4°)  Dist.Diag.30
06/06/2017  VENEZIA 24-12  (2°-4°)
Ambi ISOTOPI

su cagliari e milano manca la terzina simmetrica che e in prima posizione  ce il 7 e il 37  la terzina mancante è il 67
mentre in 2posizione ce 34 è 64 manca il 4 terzina simmetrica di 4-34-64
quindi nel mezzo delle due estrazioni mi stampa la condizione da giocare con le ruote cosi
cagliari milano 4-67
stessa cosa deve fare alle condizioni trovate come napoli venezia
sotto a cagliari milano mette la condizione di napoli venezia con le due terzine mancanti 42-54
e se trova altre condizioni li mette sotto
ma di solito non ne trova molte al massimo 2 o tre dovrebbe trovarne dipende
e poi nella estrazioni di destra cercare i numeri che stampa in mezzo delle estrazioni segnandoli di rosso
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: help my
« Reply #144 on: August 06, 2020, 07:52:34 pm »
Hi kiara87
please give a look at this program, it may be a good start to get your goal....you must add the date code like that made by Bplus and you have completed the program about AMBO ISOTOPI
https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537
------------------------
Ciao kiara87
potresti dare uno sguardo a questo programma, esso potrebbe essere un buon inizio per il tuo obiettivo.... tu devi aggiungere il codice per ottenere la data di estrazione come quello fatto da Bplus e così dovresti aver completato il programma su AMBO ISOTOPI.  https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537

Programming isn't difficult, only it's  consuming time and coffee

Offline Kiara87

  • Forum Regular
  • Posts: 164
Re: help my
« Reply #145 on: August 07, 2020, 03:07:26 am »
grazie @TempodiBasic


Hi kiara87
please give a look at this program, it may be a good start to get your goal....you must add the date code like that made by Bplus and you have completed the program about AMBO ISOTOPI
https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537
------------------------
Ciao kiara87
potresti dare uno sguardo a questo programma, esso potrebbe essere un buon inizio per il tuo obiettivo.... tu devi aggiungere il codice per ottenere la data di estrazione come quello fatto da Bplus e così dovresti aver completato il programma su AMBO ISOTOPI.  https://www.qb64.org/forum/index.php?topic=2891.msg121537#msg121537

si questo e proprio quello che cercavo hai trovato il giusto argoritmo
nel mio caso non riuscivo anche perche non sono esperto ancora cerco di imparare
guardando i vostri progetti
come risposto nel tuo thear
devo finire questo progetto aggiungendo la data e cercando i numeri nella estrazione di destra
e dove trova la condizione stampa anche le rote
questo e un programma complesso però credo anche si cresce nella programmazione una volta riuscito a creare qualcosa del genere
bhe credo che cè sempre da imparare cose nuove
forse per creare quello che ho cercato di fare io ci vogliono tanti anni di esperienza
ecco il perchè ho chiesto qui nel forum
comunque devo farti veramente i complimenti ad aver trovato l'algoritmo giusto
adesso devo trovare per finirlo cercherò di studiarlo come faccio ogni giorno
marari riuscirò
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: help my
« Reply #146 on: August 08, 2020, 03:02:14 pm »
Hi kiara87
fine to see that the uncomplete code posted does what you are trying to get... but for me it has been very difficult to understand some concepts that are behind your request and are not visible until, time after time, they came out from your words...

about
Quote
devo finire questo progetto aggiungendo la data e cercando i numeri nella estrazione di destra
e dove trova la condizione stampa anche le rote
questo e un programma complesso però credo anche si cresce nella programmazione una volta riuscito a creare qualcosa del genere
bhe credo che cè sempre da imparare cose nuove

these more features are well in the range of your coding ability! But remember first design plan of the actions  then translate this last in QB64!
And I agree only writing programs you can grow...

Good continuing programming
--------------------
bene vedo che il codice incompleto pubblicato fa quello che stai cercando di ottenere ... ma per me è stato molto difficile capire alcuni concetti che stanno dietro la tua richiesta e non sono visibili finché, di volta in volta, non sono usciti dalla tua parole...
riguardo a
Quote
devo finire questo progetto aggiungendo la data e cercando i numeri nella estrazione di destra
e dove trova la condizione stampa anche le rote
questo e un programma complesso però credo anche si cresce nella programmazione una volta riuscito a creare qualcosa del genere
beh credo che cè sempre da imparare cose nuove
queste altre funzionalità rientrano nella gamma delle tue capacità di codifica! Ma ricorda prima il piano di progettazione delle azioni, quindi traduci quest'ultimo in QB64!
E sono d'accordo che solo scrivendo programmi puoi crescere ...

Buona continuazione della programmazione
Programming isn't difficult, only it's  consuming time and coffee

Offline Kiara87

  • Forum Regular
  • Posts: 164
Re: help my
« Reply #147 on: September 07, 2020, 05:46:19 pm »
Hi kiara87

--------------------
bene vedo che il codice incompleto pubblicato fa quello che stai cercando di ottenere ... ma per me è stato molto difficile capire alcuni concetti che stanno dietro la tua richiesta e non sono visibili finché, di volta in volta, non sono usciti dalla tua parole...
riguardo a queste altre funzionalità rientrano nella gamma delle tue capacità di codifica! Ma ricorda prima il piano di progettazione delle azioni, quindi traduci quest'ultimo in QB64!
E sono d'accordo che solo scrivendo programmi puoi crescere ...

Buona continuazione della programmazione

bhe ho provato ad inserire le funzioni che ho citato fino ad oggi non riesco
eppure ho studiato le istruzioni del basic pero' per far questo genere di programma si deve essere veramente esperti
credo che tempodibasic puo aiutarmi se legge il messaggio
@TempodiBasic  se m leggi
help my

Code: QB64: [Select]
  1. ' Programma lotto di kiara87
  2. ' il programma legge i dati (numeri estratti da un file.dat)
  3. ' e permette di vedere  le estrazioni a video
  4. ' i numeri con distanza 30 sono evidenziati con colore rosso
  5. ' questi numeri vengono memorizzati e stampati
  6.  
  7. ' Nota 1: sono d'accordo con Bplus e' molto piu'
  8. ' rapido lavorare con dati in RAM che con dati su Disco HDD/SSD/USB/CD/DVD
  9.  
  10. 'nota 2: si e' scoperto che la distanza 30 e' aritmologica ossia
  11. ' in un sistema ciclico 1-90 per cui se si va oltre il limite si ritorna nel range 1-90
  12. ' invece di pensare i numeri su di una linea retta bisogna pensarli su una
  13. ' linea a cerchio per cui sottrarre o aggiungere equivale a spostarsi indietro
  14. ' o in avanti di un numero specificato di posizioni
  15.  
  16. 'nota 3: lo scopo della ricerca delle coppie di numeri distanti 30 unita'
  17. ' e' quello di individuare la terzina simmetrica con passo 30 che e' interessata
  18. ' (ossia che con 2 numeri forma un ambo) per cercare gli AMBI ISOTOPI
  19. ' (ossia due coppie di numeri che nella griglia delle estrazioni mostrano
  20. ' la stessa posizione formando un quadrilatero)
  21.  
  22. 'nota 4: la coppia di numeri di una terzina simmetrica puo' essere
  23. ' in orizzontale  ( i numeri sono nella stessa ruota di estrazione)
  24. ' in verticale ( i numeri sono nella ' stessa posizione di estrazione tipo 1 estratto,
  25. ' 2 estratto...5 estratto)
  26. ' in diagonale (i numeri appartengono a ruota estrattiva e colonna estrattiva diverse)
  27. '
  28.  
  29. ' valori COSTANTI  generali Vero e Falso
  30. CONST True = -1, False = NOT True
  31. ' le 11 ruote del lotto
  32. CONST Bari = 1, Cagliari = 2, Firenze = 3, Genova = 4, Milano = 5
  33. CONST Napoli = 6, Palermo = 7, Roma = 8, Torino = 9, Venezia = 10, Nazionale = 11
  34. CONST Cifra = 2 ' ogni numero estratto e' una cifra di due caratteri (01-90)
  35.  
  36. DIM a AS STRING ' una stringa per leggere i dati dal file
  37.  
  38. ' salta al sottoprogramma LeggiFile delimitato
  39. ' dalla Label LeggiFIle e dal RETURN
  40. GOSUB LeggiFile
  41.  
  42. ' verifica che tutto il file sia letto
  43. 'FOR b = 1 TO LEN(a) - 116 STEP 116
  44. '    PRINT MID$(a, b, 116)
  45. '    '    PRINT INSTR(b, a, CHR$(13))
  46. '    _DELAY .1
  47. 'NEXT b
  48.  
  49.  
  50.  
  51. ' il ciclo DO...LOOP UNTIL condizione e' un modo piu' moderno
  52. ' rispetto a Etichetta: .... IF condizione GOTO Etichetta
  53. b = 1 ' flag che conta la posizione di lettura nel file  per il riquadro sinistro
  54. f = 1 ' flag che conta la posizione di lettura nel file  per il riquadro destro
  55. z$ = " " ' flag per l'output a schermo del programma
  56. OPEN "distanza30.dat" FOR APPEND AS #2 ' apertura del file dei risultati
  57.     IF z$ <> "" THEN ' se non c'e' input non viene eseguito
  58.         CLS ' questo risolve un glitch di output sullo schermo
  59.         ' in alternativa alla riga sopra CLS nel sottoblocco
  60.         ' MostraEstratti va stampata la stringa estratto e
  61.         ' non il suo valore corrispondente ottenuto con VAL
  62.         GOSUB MostraRuote ' scrive il nome delle ruote del lotto
  63.         GOSUB MostraEstratti ' scrive le estrazioni
  64.         GOSUB cerca30 ' evidenzia gli ambi isotopi nella estrazione di sinistra
  65.         ' e se la terzina simmetrica e' incompleta  segnala il numero mancante
  66.     END IF
  67.     ' prende l'input dell'utente
  68.     z$ = UCASE$(INKEY$) ' Z$ mantiene il maiuscolo di Inkey$
  69.     IF z$ = CHR$(0) + CHR$(72) AND b < (LEN(a) - 116) THEN b = b + 116
  70.     IF z$ = CHR$(0) + CHR$(80) AND b > 116 THEN b = b - 116
  71.     IF z$ = "+" AND f < (LEN(a) - 116) THEN f = f + 116
  72.     IF z$ = "-" AND f > 116 THEN f = f - 116
  73.     IF z$ <> "" THEN riga = 0
  74. LOOP UNTIL z$ = "Q" ' esegue questo ciclo fino a che si preme q per quit
  75. CLOSE #2 ' chiude il file che memorizza i distanti 30 per ogni estrazione esaminata a video
  76.  
  77. END ' indica la fine logica del programma
  78.  
  79.  
  80. '-----------------------AREA sottoprogrammi /SUBroutines
  81.  
  82. ' questa etichetta /label indica il punto di inizio
  83. ' del sottoprogramma (SUBroutine) LeggiFile scritto con vecchio stile GOSUB
  84. ' che usa una etichetta/label e un RETURN per riprendere da dove si era interotto
  85. ' nota1: un metodo ancora piu' antico e' il salto con GOTO
  86. '        che richiede una seconda etichetta per ritornare nel MAIN o programma principale
  87. ' nota2: un metodo migliore e' SUB nomeroutine....END SUB
  88. '        perche' permette la localizzazione delle variabili
  89. LeggiFile:
  90. 'se non trova lotto.dat segnala l'errore a video e termina il programma
  91. IF NOT _FILEEXISTS("lotto.dat") THEN PRINT "File non trovato": END
  92. '<--------------------
  93. ' questo metodo e' piu' lento
  94. ' apre il file lotto.dat per leggere in maniera sequenziale i dati
  95. 'OPEN "lotto.dat" FOR INPUT AS #1
  96. 'LINE INPUT #1, a  ' riempe la variabile a con una riga intera di valori
  97. '<--------------------
  98.  
  99. ' apre lotto.dat per leggerlo in maniera binaria
  100. OPEN "lotto.dat" FOR BINARY AS #1
  101. a = SPACE$(LOF(1)) ' riempe la variabile a di spazi fino alla grandezza in byte del file aperto
  102. GET #1, , a ' legge con una unica operazione il file e lo pone nella variabile a
  103. CLOSE #1 ' chiude il file appena letto
  104. ' indica il termine della SUBroutine LeggiFile
  105. ' e RITORNA alla riga di codice successiva al salto GOSUB
  106.  
  107. 'seconda SUBroutine /sottoprogramma
  108. MostraRuote:
  109. LOCATE 1, 1
  110. PRINT "DATA ESTRAZIONALE"
  111. LOCATE 2, 1
  112. PRINT "BARI"
  113. LOCATE 4, 1
  114. PRINT "CAGLIARI"
  115. LOCATE 6, 1
  116. PRINT "FIRENZE"
  117. LOCATE 8, 1
  118. PRINT "GENOVA"
  119. LOCATE 10, 1
  120. PRINT "MILANO"
  121. LOCATE 12, 1
  122. PRINT "NAPOLI"
  123. LOCATE 14, 1
  124. PRINT "PALERMO"
  125. LOCATE 16, 1
  126. PRINT "ROMA"
  127. LOCATE 18, 1
  128. PRINT "TORINO"
  129. LOCATE 20, 1
  130. PRINT "VENEZIA"
  131. LOCATE 22, 1
  132. PRINT "NAZIONALE"
  133. LOCATE 1, 49
  134. PRINT "DATA ESTRAZIONALE"
  135. LOCATE 2, 49
  136. PRINT "BARI"
  137. LOCATE 4, 49
  138. PRINT "CAGLIARI"
  139. LOCATE 6, 49
  140. PRINT "FIRENZE"
  141. LOCATE 8, 49
  142. PRINT "GENOVA"
  143. LOCATE 10, 49
  144. PRINT "MILANO"
  145. LOCATE 12, 49
  146. PRINT "NAPOLI"
  147. LOCATE 14, 49
  148. PRINT "PALERMO"
  149. LOCATE 16, 49
  150. PRINT "ROMA"
  151. LOCATE 18, 49
  152. PRINT "TORINO"
  153. LOCATE 20, 49
  154. PRINT "VENEZIA"
  155. LOCATE 22, 49
  156. PRINT "NAZIONALE"
  157.  
  158. LOCATE 23, 50
  159. PRINT "+ avanti  - indietro"
  160. LOCATE 23, 1
  161. PRINT CHR$(24); " avanti   "; CHR$(25); " indietro"
  162.  
  163. ' indica il termine della SUBroutine MostraRuote
  164. ' e RITORNA alla riga di codice successiva al salto GOSUB
  165.  
  166. 'terzo sottoprogramma o SUBroutine
  167. MostraEstratti:
  168. ' le prime 4 cifre sembrano essere il numero della estrazione
  169. LOCATE 1, 32
  170. PRINT "estraz.num "; MID$(a, b, 4)
  171. PRINT #2, "estraz.num "; MID$(a, b, 4)
  172. y = 12 ' prima posizione per il carattere da stampare
  173. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  174.     A1 = "" ' resetto a1 per il prossimo giro
  175.     FOR V = Bari TO Nazionale ' per tutte le ruote
  176.         COLOR 15, 0
  177.         'posiziona il cursore
  178.         LOCATE (V * 2 + 1) - 1, y ' prima estrazione scoperta by MCN
  179.         ' scrive il numero estratto
  180.         PRINT (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra)); " ";
  181.         A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (b - 1), Cifra))
  182.     NEXT V
  183.     y = POS(0)
  184. ' indica il termine della SUBroutine MostraEstratti
  185. ' e RITORNA alla riga di codice successiva al salto GOSUB
  186. LOCATE 23, 32
  187. PRINT "estraz.num "; MID$(a, f, 4)
  188. PRINT #2, "estraz.num "; MID$(a, f, 4)
  189.  
  190. y = 60 ' prima posizione per il carattere da stampare
  191. FOR x = 1 TO 5 STEP 1 ' questo ciclo   FOR e' di 5 perche' ogni ruota ha 5 estrazioni
  192.     A1 = "" ' resetto a1 per il prossimo giro
  193.     FOR V = Bari TO Nazionale ' per tutte le ruote
  194.         COLOR 15, 0
  195.         'posiziona il cursore
  196.         LOCATE (V * 2 + 1) - 1, y ' seconda estrazione scoperta by mcn
  197.         ' scrive il numero estratto
  198.         PRINT (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra)); " ";
  199.         A1 = A1 + (MID$(a, (V - 1) * 10 + 5 + ((x - 1) * 2) + (f - 1), Cifra))
  200.     NEXT V
  201.     y = POS(0)
  202. ' indica il termine della SUBroutine MostraEstratti
  203. ' e RITORNA alla riga di codice successiva al salto GOSUB
  204.  
  205.  
  206. ' essendo la distanza30 orizzontale e la distanza30 verticale due condizioni
  207. ' particolari della distanza 30 diagonale allora bastera' calcolare questa ultima
  208. ' per calcolare anche le altre...questo trasforma la ricerca da 1 vs 1 con una
  209. ' specifica condizione (stessa riga o stessa colonna) in 1 vs 1 in cui il secondo
  210. ' appartiene al sottoinsieme ruota in esame (v) to nazionale e 1 to 5 estratti (x)
  211. ' quindi dopo aver mostrato le estrazioni va chiamata la subroutine per cercare
  212. ' un ambo con 2 numeri della terzina simmetrica con passo 30
  213. cerca30:
  214. FOR x1 = 1 TO 5 STEP 1
  215.     FOR v1 = Bari TO Venezia STEP 1
  216.         ' estraggo  il numero dall'elenco
  217.         num = VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra))
  218.         ' calcolo il numero precedente e successivo al numero estratto
  219.         IF num < 30 THEN prev = num - 30 + 90 ELSE prev = num - 30
  220.         IF num > 60 THEN succ = num + 30 - 90 ELSE succ = num + 30
  221.         FOR x2 = x1 TO 5
  222.             FOR v2 = v1 TO Nazionale 'per le restanti ruote
  223.                 num2 = VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra))
  224.                 IF num2 = prev OR num2 = succ THEN GOSUB AmboIsotopi
  225.             NEXT v2
  226.         NEXT x2
  227.     NEXT v1
  228. NEXT x1
  229.  
  230.  
  231. AmboIsotopi:
  232. 'cerca nell'intervallo della coppia trovata
  233.  
  234. IF x1 <> x2 THEN
  235.     ' i 2 numeri sono su 2 colonne diverse
  236.     IF v1 <> v2 THEN
  237.         ' i 2 numeri sono su due righe diverse
  238.         ' quindi i 2 numeri sono in diagonale
  239.         num3 = VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra))
  240.         num4 = VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra))
  241.         IF num3 < 30 THEN prev1 = num3 - 30 + 90 ELSE prev1 = num3 - 30
  242.         IF num3 > 60 THEN succ1 = num3 + 30 - 90 ELSE succ1 = num3 + 30
  243.         'se hanno distanza 30 abbiamo trovato un   Ambo Isotopo
  244.         IF num4 = prev1 OR num4 = succ1 THEN GOSUB AmboOk
  245.     ELSE
  246.         ' v1 = v2  i 2 numeri sono sulla stessa riga
  247.         FOR v3 = v1 + 1 TO v2 STEP 1
  248.             num3 = VAL(MID$(a, (v3 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra))
  249.             num4 = VAL(MID$(a, (v3 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra))
  250.             IF num3 < 30 THEN prev1 = num3 - 30 + 90 ELSE prev1 = num3 - 30
  251.             IF num3 > 60 THEN succ1 = num3 + 30 - 90 ELSE succ1 = num3 + 30
  252.             'se hanno distanza 30 abbiamo trovato un   Ambo Isotopo
  253.             IF num4 = prev1 OR num4 = succ1 THEN GOSUB AmboOk
  254.         NEXT v3
  255.         v3 = 0
  256.     END IF
  257.     ' x1 = x2    i 2 numeri sono sulla stessa colonna
  258.     IF v1 <> v2 THEN
  259.         ' i 2 numeri sono su diverse righe
  260.         FOR x3 = x1 + 1 TO x2 STEP 1
  261.             num3 = VAL(MID$(a, (v1 - 1) * 10 + 5 + ((x3 - 1) * 2) + (b - 1), Cifra))
  262.             num4 = VAL(MID$(a, (v2 - 1) * 10 + 5 + ((x3 - 1) * 2) + (b - 1), Cifra))
  263.             IF num3 < 30 THEN prev1 = num3 - 30 + 90 ELSE prev1 = num3 - 30
  264.             IF num3 > 60 THEN succ1 = num3 + 30 - 90 ELSE succ1 = num3 + 30
  265.             'se hanno distanza 30 abbiamo trovato un   Ambo Isotopo
  266.             IF num4 = prev1 OR num4 = succ1 THEN GOSUB AmboOk
  267.         NEXT x3
  268.         x3 = 0
  269.     ELSE
  270.         ' i 2 numeri sono sulla stessa riga
  271.         ' v1 = v2
  272.         ' e' il caso impossibile perche' i due numeri coincidono con uno solo
  273.     END IF
  274.  
  275.  
  276. AmboOk:
  277. ' evidenzia sulla tabella estrattiva di sinistra i numeri trovati e
  278. ' scrive al centro i numeri mancanti della terzina simmetrica
  279. IF riga < 4 THEN riga = 4 ELSE riga = riga + 2
  280. k = 11
  281. 'posiziona il cursore
  282. LOCATE (v1 * 2 + 1) - 1, k + (x1 * 3) - 2 'IL PRIMO NUMERO TROVATO COLORATO LO POSIZIONA GIUSTO BY MCN
  283. ' scrive il numero estratto
  284. PRINT (MID$(a, (v1 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra));
  285. 'posiziona il cursore
  286. LOCATE (v2 * 2 + 1) - 1, k + (x2 * 3) - 2 'IL SECONDO NUMERO TROVATO LO POSIZIONA GIUSTO E LO COLORA BY MCN
  287. ' scrive il numero estratto
  288. PRINT (MID$(a, (v2 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra));
  289. IF x1 <> x2 THEN
  290.     IF v1 <> v2 THEN
  291.         'posiziona il cursore
  292.         LOCATE (v1 * 2 + 1) - 1, (x2 * 3) + k - 2 'IL TERZO NUMERO TROVATO LO POSIZIONA E COLORA BY MCN
  293.         ' scrive il numero estratto
  294.         PRINT (MID$(a, (v1 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra));
  295.  
  296.         'posiziona il cursore
  297.         LOCATE (v2 * 2 + 1) - 1, (x1 * 3) - 2 + k 'QUARTO NUMERO ESTRATTO TROVATO E POSIZIONA NELL CURSORE DEL NUMERO E LO COLORA BY MCN
  298.         ' scrive il numero estratto
  299.         PRINT (MID$(a, (v2 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra));
  300.     ELSE
  301.         'v1 = v2
  302.         'posiziona il cursore
  303.         LOCATE (v3 * 2) - 1, (x1 * 3) - 2 + k
  304.         ' scrive il numero estratto
  305.         PRINT (MID$(a, (v3 - 1) * 10 + 5 + ((x1 - 1) * 2) + (b - 1), Cifra));
  306.  
  307.         'posiziona il cursore
  308.         LOCATE (v3 * 2) - 1, (x2 * 3) - 2 + k
  309.         ' scrive il numero estratto
  310.         PRINT (MID$(a, (v3 - 1) * 10 + 5 + ((x2 - 1) * 2) + (b - 1), Cifra));
  311.     END IF
  312.     ' x1 = x2
  313.  
  314.     IF v1 <> v2 THEN
  315.         'posiziona il cursore
  316.         LOCATE (v3 * 2) - 1, ((x1 - 1) * 3) - 2 + k
  317.         ' scrive il numero estratto
  318.         PRINT (MID$(a, (v1 - 1) * 10 + 5 + ((x3 - 1) * 2) + (b - 1), Cifra));
  319.  
  320.         'posiziona il cursore
  321.         LOCATE (v3 * 2) - 1, ((x2 - 1) * 3) - 2 + k
  322.         ' scrive il numero estratto
  323.         PRINT (MID$(a, (v2 - 1) * 10 + 5 + ((x3 - 1) * 2) + (b - 1), Cifra));
  324.     ELSE
  325.         ' v1 = v2 e' il caso impossibile
  326.     END IF
  327. LOCATE riga, 35:
  328. IF num2 = prev THEN PRINT succ; ELSE PRINT prev;
  329. PRINT "--";
  330. IF num4 = prev1 THEN PRINT succ1; ELSE PRINT prev1;
  331.  
  332. COLOR 15, 0
  333.  
  334.  
  335.  
  336.  
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: help my
« Reply #148 on: September 07, 2020, 06:57:38 pm »
Hi Kiara87

1. for the first step  follow this link
https://translate.google.it/?hl=it#view=home&op=translate&sl=it&tl=en&text=aiutami and so you can gain the right way to say aiutami

2.
your project is
Quote
devo finire questo progetto aggiungendo la data e cercando i numeri nella estrazione di destra
e dove trova la condizione stampa anche le rote
questo e un programma complesso però credo anche si cresce nella programmazione una volta riuscito a creare qualcosa del genere
beh credo che cè sempre da imparare cose nuove
-add the date in the middle of two extractions
 - search the suggested number into the  extraction on the right
 - print on the screen the wheels of that numbers

as soon as I have some time I'll post something for you.
Programming isn't difficult, only it's  consuming time and coffee

Offline Kiara87

  • Forum Regular
  • Posts: 164
Re: help my
« Reply #149 on: September 07, 2020, 07:30:56 pm »
Hi Kiara87

1. for the first step  follow this link
https://translate.google.it/?hl=it#view=home&op=translate&sl=it&tl=en&text=aiutami and so you can gain the right way to say aiutami

2.
your project is -add the date in the middle of two extractions
 - search the suggested number into the  extraction on the right
 - print on the screen the wheels of that numbers

as soon as I have some time I'll post something for you.

thanks @TempodiBasic
you are really kind
se avessi solo un'ora per salvare il mondo, passerei 55 minuti per definire bene il problema e 5 a trovare la soluzione