Author Topic: Mega sena database  (Read 18812 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Mega sena database
« on: March 26, 2019, 08:22:59 pm »
Good night,
I'm trying to create a database with 50 million dozens of Mega Sena. But when it arrives at a certain point, the program will no longer check the number generated in the database. I ask for your help.
  Follow the code in TXT.

Below is the purpose of this program.
1) Generate combination
2) Check if it already exists
3) If it does not exist, save
4) Return to step 1

thanks in advance
* Gera Combinações_25.txt (Filesize: 5.02 KB, Downloads: 226)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #1 on: March 27, 2019, 09:54:39 am »
Hi carloscordeiro,

I looked at your code and can not figure what is going on?

If you are generating combinations or permutations, there are certainly better ways than randomly making one up and then checking if you have it already.

Quote
But when it arrives at a certain point, the program will no longer check the number generated in the database.

This is likely caused by exceeding a limit for a variable type. If you can put a number on when the "certain point" occurs, it might indicate which variable needs a bigger type.

I noticed the program uses DEFINT A-Z making any undeclared variable type an integer which is pretty small for a program involving "millions". I would drop that line and let the default then be SINGLE precision which will give much more range.

For instance:
Code: QB64: [Select]
  1.     OPEN "Gera.dat" FOR BINARY AS #1
  2.     tamArq = LOF(1)
  3.     CLOSE #1
  4.  
tamArq was NOT declared with a type so it takes default integer, my guess is the binary file will soon exceed integer limit of 32 thousand plus so use of the variable will cause errors.

Welcome to the forum!




Append: I have looked up Mega Sensa, a Brazil Lottery pick numbers 1 to 60
https://en.wikipedia.org/wiki/Mega-Sena
Quote
When 6 unique 2 digit numbers are drawn, the drawing is concluded.

Betting
Contestants may bet in the range of 6 to 15 numbers, out of 60, and scoring 4, 5 or 6 points will grant prizes. Bet prices escalate depending on how many possible groups of 6 numbers exist within the numbers chosen, so they vary between R$3.50 for 6 numbers (only 1 game possible) to R$17,517.50 for 15 numbers (5005 games possible). The chances of winning the biggest prize when placing a minimum bet are 1 in 50,063,860.
Yikes! that seems complicated.

As I understand this lottery:
So if you pick 6 numbers and they all hit, that's a bigger (the biggest prize) but if you pick 12 numbers and 6 hit that's a way smaller prize. ?
« Last Edit: March 27, 2019, 10:36:42 am by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Mega sena database
« Reply #2 on: March 27, 2019, 05:32:47 pm »
I am curious. Regardless as to how simple or complicated the program is, I have to conclude that, picking lottery numbers is either a 'see if it can be done' or 'just for the fun of it'.

One can hardly use a program, such as this, to actually generate lottery number ticket entries. If this program generates 'millions' of combinations, it would be self defeating, as the shear cost of the tickets... ('millions' x $ per ticket).... I'm over-thinking this again aren't I? (beat ya to it bplus... lol)
Logic is the beginning of wisdom.

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mega sena database
« Reply #3 on: March 27, 2019, 06:37:24 pm »
Good night
Thanks for answering.
I am generating combinations to confront Brazilian mathematicians. They say the chance to win the lottery is from 1 to 50,063,860. I decided to develop this program to generate 50,063,860.
I'm having a hard time making it generate without repeating any combination. I do not have much experience with Qbasic.
I removed the DEFINT AZ line, and continued generating repeated combinations

I ask for help on how to do it better than mine.

Attached is the code that checks whether 50,063,860 will fall into the draw of the week.
* Confere Combianacoes.txt (Filesize: 7.33 KB, Downloads: 201)
Imagem Pesquisa Mega.jpg
* Imagem Pesquisa Mega.jpg (Filesize: 120.66 KB, Dimensions: 655x786, Views: 384)
« Last Edit: March 27, 2019, 07:06:53 pm by carloscordeiro »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #4 on: March 27, 2019, 07:23:35 pm »
Do you know the formula for telling how many combinations can be made from a set of 60 elements, taking them 6 at a time?

It is 60! (which is 60*59*58*57*56*.... *3*2*1) divided by (6!)*(54!) my Windows calculator tells me this is 50,063,860 (Thanks Qwerky for alerting me to N! in the Window's calculator.)

Why do you need to write every one down?

Generating them randomly will never assure you have every one.



Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mega sena database
« Reply #5 on: March 27, 2019, 09:10:27 pm »
I decided to try to develop this program with RANDOMIZE TIMER, to know if the program would be able to sort out the sequence: 01,02,03,04,05,06 as mathematicians claim that the chances of getting a combination of this are the same as leaving 05,10,12,18,25,33.

I have no hurry. Even if the PC takes 3 months to run RANDOMIZE TIMER, I hope it will exit this sequence.
I'd love your help, to change some line of code that is not as it should.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #6 on: March 28, 2019, 09:08:46 am »
I'd love to help but the numbers involved are too great!

There is a way to systematically list 60! Permutations* BUT 60! permutations is:
 
60! is.PNG


But to systematically list combinations for r groups in smaller sets of n elements (say, 10 with 3,628,800 permutations or less) is interesting program challenge.

Challenge is to code this system of counting in order Combinations!
Code: QB64: [Select]
  1. 4 elements
  2. 1, 2, 3, 4 taken 2 at a time
  3.  
  4. systematic and ordered
  5. 1, 2
  6. 1, 3
  7. 1, 4
  8. 2, 3
  9. 2, 4
  10. 3, 4
  11. 6 combinations: check rCn = 4! / (2! * 2!) = 4*3*2 / (2*2) = 6
  12.  
  13. 5 elements 3 at a time
  14. 1, 2, 3
  15. 1, 2, 4
  16. 1, 2, 5
  17. 1, 3, 4
  18. 1, 3, 5
  19. 1, 4, 5
  20. 2, 3, 4
  21. 2, 3, 5
  22. 2, 4, 5
  23. 3, 4, 5
  24. 10 combinations: check rCn = 5! /(3! * 2!) = 5*4*3*2 / (3*2 * 2) = 5*2 = 10
  25.  
  26. 7 elements 3 at a time rCn = 35
  27. 1, 2, 3
  28. 1, 2, 4
  29. 1, 2, 5
  30. 1, 2, 6
  31. 1, 2, 7
  32. 1, 3, 4
  33. 1, 3, 5
  34. 1, 3, 6
  35. 1, 3, 7
  36. 1, 4, 5
  37. 1, 4, 6
  38. 1, 4, 7
  39. 1, 5, 6
  40. 1, 5, 7
  41. 1, 6, 7    16
  42. 2, 3, 4
  43. 2, 3, 5
  44. 2, 3, 6
  45. 2, 3, 7
  46. 2, 4, 5
  47. 2, 4, 6
  48. 2, 4, 7
  49. 2, 5, 6
  50. 2, 5, 7
  51. 2, 6, 7   +10
  52. 3, 4, 5
  53. 3, 4, 6
  54. 3, 4, 7
  55. 3, 5, 6
  56. 3, 5, 7  
  57. 3, 6, 7   +6
  58. 4, 5, 6
  59. 4, 5, 7   +2
  60. 5, 6, 7   +1
  61. 35 combinations: rCn = 7*6*5 / 3*2 = 35

* The way is to count in base 60 and remove all numbers where a "digit" was used more than once.
« Last Edit: March 28, 2019, 09:20:16 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #7 on: March 28, 2019, 09:51:41 am »
hmm... now that I see a way of counting up combinations by hand, I see that programming that to do 50 million might not take so long after all and not nearly as hard as the other way I was imagining.

This is doable!




Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Mega sena database
« Reply #8 on: March 28, 2019, 10:06:26 am »
If you want a list of all the possible combinations, then what you want is something like the following:

Code: QB64: [Select]
  1. PRINT "Calculating..."
  2. OPEN "temp.txt" FOR OUTPUT AS #1
  3. FOR num1 = 1 TO 55
  4.     LOCATE 2, 1: PRINT num1,
  5.     FOR num2 = num1 + 1 TO 56
  6.         LOCATE 3, 1: PRINT num2,
  7.         FOR num3 = num2 + 1 TO 57
  8.             LOCATE 4, 1: PRINT num3,
  9.             FOR num4 = num3 + 1 TO 58
  10.                 LOCATE 5, 1: PRINT num4,
  11.                 FOR num5 = num4 + 1 TO 59
  12.                     LOCATE 6, 1: PRINT num5,
  13.                     FOR num6 = num5 + 1 TO 60
  14.                         LOCATE 7, 1: PRINT num6
  15.                         s$ = LTRIM$(STR$(num1)) + ","
  16.                         IF num1 < 10 THEN s$ = "0" + s$
  17.                         IF num2 < 10 THEN s$ = s$ + "0"
  18.                         s$ = s$ + LTRIM$(STR$(num2)) + ","
  19.                         IF num3 < 10 THEN s$ = s$ + "0"
  20.                         s$ = s$ + LTRIM$(STR$(num3)) + ","
  21.                         IF num4 < 10 THEN s$ = s$ + "0"
  22.                         s$ = s$ + LTRIM$(STR$(num4)) + ","
  23.                         IF num5 < 10 THEN s$ = s$ + "0"
  24.                         s$ = s$ + LTRIM$(STR$(num5)) + ","
  25.                         IF num6 < 10 THEN s$ = s$ + "0"
  26.                         s$ = s$ + LTRIM$(STR$(num6))
  27.                         PRINT #1, s$
  28.                     NEXT
  29.                 NEXT
  30.             NEXT
  31.         NEXT
  32.     NEXT
  33.  

This will generate all the possible 50 million possibilities and save them to a file called "temp.txt" on your hard drive.  From just a little output, it's quite easy to see how it's working:

Code: QB64: [Select]
  1. 01,02,03,04,05,06
  2. 01,02,03,04,05,07
  3. 01,02,03,04,05,08
  4. 01,02,03,04,05,09
  5. 01,02,03,04,05,10
  6. 01,02,03,04,05,11
  7. 01,02,03,04,05,12
  8. 01,02,03,04,05,13
  9. 01,02,03,04,05,14
  10. 01,02,03,04,05,15
  11. 01,02,03,04,05,16
  12. 01,02,03,04,05,17
  13. 01,02,03,04,05,18
  14. 01,02,03,04,05,19
  15. 01,02,03,04,05,20
  16. 01,02,03,04,05,21
  17. 01,02,03,04,05,22
  18. 01,02,03,04,05,23
  19. 01,02,03,04,05,24
  20. 01,02,03,04,05,25
  21. 01,02,03,04,05,26
  22. 01,02,03,04,05,27
  23. 01,02,03,04,05,28
  24. 01,02,03,04,05,29
  25. 01,02,03,04,05,30
  26. 01,02,03,04,05,31
  27. 01,02,03,04,05,32
  28. 01,02,03,04,05,33
  29. 01,02,03,04,05,34
  30. 01,02,03,04,05,35
  31. 01,02,03,04,05,36
  32. 01,02,03,04,05,37
  33. 01,02,03,04,05,38
  34. 01,02,03,04,05,39
  35. 01,02,03,04,05,40
  36. 01,02,03,04,05,41
  37. 01,02,03,04,05,42
  38. 01,02,03,04,05,43
  39. 01,02,03,04,05,44
  40. 01,02,03,04,05,45
  41. 01,02,03,04,05,46
  42. 01,02,03,04,05,47
  43. 01,02,03,04,05,48
  44. 01,02,03,04,05,49
  45. 01,02,03,04,05,50
  46. 01,02,03,04,05,51
  47. 01,02,03,04,05,52
  48. 01,02,03,04,05,53
  49. 01,02,03,04,05,54
  50. 01,02,03,04,05,55
  51. 01,02,03,04,05,56
  52. 01,02,03,04,05,57
  53. 01,02,03,04,05,58
  54. 01,02,03,04,05,59
  55. 01,02,03,04,05,60
  56. 01,02,03,04,06,07

First, all the possible numbers starting with 1, 2, 3, 4, 5...
Then all the possible numbers starting with 1, 2, 3, 4, 6... 

And so on, until we generate the whole list and save it on our drive as single line text combinations.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #9 on: March 28, 2019, 10:14:05 am »
If you want a list of all the possible combinations, then what you want is something like the following:

Code: QB64: [Select]
  1. PRINT "Calculating..."
  2. OPEN "temp.txt" FOR OUTPUT AS #1
  3. FOR num1 = 1 TO 55
  4.     LOCATE 2, 1: PRINT num1,
  5.     FOR num2 = num1 + 1 TO 56
  6.         LOCATE 3, 1: PRINT num2,
  7.         FOR num3 = num2 + 1 TO 57
  8.             LOCATE 4, 1: PRINT num3,
  9.             FOR num4 = num3 + 1 TO 58
  10.                 LOCATE 5, 1: PRINT num4,
  11.                 FOR num5 = num4 + 1 TO 59
  12.                     LOCATE 6, 1: PRINT num5,
  13.                     FOR num6 = num5 + 1 TO 60
  14.                         LOCATE 7, 1: PRINT num6
  15.                         s$ = LTRIM$(STR$(num1)) + ","
  16.                         IF num1 < 10 THEN s$ = "0" + s$
  17.                         IF num2 < 10 THEN s$ = s$ + "0"
  18.                         s$ = s$ + LTRIM$(STR$(num2)) + ","
  19.                         IF num3 < 10 THEN s$ = s$ + "0"
  20.                         s$ = s$ + LTRIM$(STR$(num3)) + ","
  21.                         IF num4 < 10 THEN s$ = s$ + "0"
  22.                         s$ = s$ + LTRIM$(STR$(num4)) + ","
  23.                         IF num5 < 10 THEN s$ = s$ + "0"
  24.                         s$ = s$ + LTRIM$(STR$(num5)) + ","
  25.                         IF num6 < 10 THEN s$ = s$ + "0"
  26.                         s$ = s$ + LTRIM$(STR$(num6))
  27.                         PRINT #1, s$
  28.                     NEXT
  29.                 NEXT
  30.             NEXT
  31.         NEXT
  32.     NEXT
  33.  

This will generate all the possible 50 million possibilities and save them to a file called "temp.txt" on your hard drive.  From just a little output, it's quite easy to see how it's working:

Code: QB64: [Select]
  1. 01,02,03,04,05,06
  2. 01,02,03,04,05,07
  3. 01,02,03,04,05,08
  4. 01,02,03,04,05,09
  5. 01,02,03,04,05,10
  6. 01,02,03,04,05,11
  7. 01,02,03,04,05,12
  8. 01,02,03,04,05,13
  9. 01,02,03,04,05,14
  10. 01,02,03,04,05,15
  11. 01,02,03,04,05,16
  12. 01,02,03,04,05,17
  13. 01,02,03,04,05,18
  14. 01,02,03,04,05,19
  15. 01,02,03,04,05,20
  16. 01,02,03,04,05,21
  17. 01,02,03,04,05,22
  18. 01,02,03,04,05,23
  19. 01,02,03,04,05,24
  20. 01,02,03,04,05,25
  21. 01,02,03,04,05,26
  22. 01,02,03,04,05,27
  23. 01,02,03,04,05,28
  24. 01,02,03,04,05,29
  25. 01,02,03,04,05,30
  26. 01,02,03,04,05,31
  27. 01,02,03,04,05,32
  28. 01,02,03,04,05,33
  29. 01,02,03,04,05,34
  30. 01,02,03,04,05,35
  31. 01,02,03,04,05,36
  32. 01,02,03,04,05,37
  33. 01,02,03,04,05,38
  34. 01,02,03,04,05,39
  35. 01,02,03,04,05,40
  36. 01,02,03,04,05,41
  37. 01,02,03,04,05,42
  38. 01,02,03,04,05,43
  39. 01,02,03,04,05,44
  40. 01,02,03,04,05,45
  41. 01,02,03,04,05,46
  42. 01,02,03,04,05,47
  43. 01,02,03,04,05,48
  44. 01,02,03,04,05,49
  45. 01,02,03,04,05,50
  46. 01,02,03,04,05,51
  47. 01,02,03,04,05,52
  48. 01,02,03,04,05,53
  49. 01,02,03,04,05,54
  50. 01,02,03,04,05,55
  51. 01,02,03,04,05,56
  52. 01,02,03,04,05,57
  53. 01,02,03,04,05,58
  54. 01,02,03,04,05,59
  55. 01,02,03,04,05,60
  56. 01,02,03,04,06,07

First, all the possible numbers starting with 1, 2, 3, 4, 5...
Then all the possible numbers starting with 1, 2, 3, 4, 6... 

And so on, until we generate the whole list and save it on our drive as single line text combinations.

There you go carloscordeiro,  there's your program!  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
You not only have a list of Combinations, you have an ordered list!


Thanks Steve, my project for this morning is done. :)  (Back to Star Wars crawl.)
« Last Edit: March 28, 2019, 10:16:59 am by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Mega sena database
« Reply #10 on: March 28, 2019, 10:40:34 am »
And if you just want the list in memory, instead of saving it to disk, use something simple like the following:

Code: QB64: [Select]
  1. DIM Combos(1 TO 50063860) AS _INTEGER64
  2. PRINT "Calculating..."
  3. OPEN "temp.txt" FOR OUTPUT AS #1
  4. FOR num1 = 1 TO 55
  5.     LOCATE 2, 1: PRINT num1,
  6.     FOR num2 = num1 + 1 TO 56
  7.         LOCATE 3, 1: PRINT num2,
  8.         FOR num3 = num2 + 1 TO 57
  9.             LOCATE 4, 1: PRINT num3
  10.             PRINT num1 / 55 * 100 + num2 / 56 + num3 / 5700; "% total complete"
  11.             FOR num4 = num3 + 1 TO 58
  12.                 FOR num5 = num4 + 1 TO 59
  13.                     FOR num6 = num5 + 1 TO 60
  14.                         s$ = LTRIM$(STR$(num1)) + ","
  15.                         IF num1 < 10 THEN s$ = "0"
  16.                         IF num2 < 10 THEN s$ = s$ + "0"
  17.                         s$ = s$ + LTRIM$(STR$(num2))
  18.                         IF num3 < 10 THEN s$ = s$ + "0"
  19.                         s$ = s$ + LTRIM$(STR$(num3))
  20.                         IF num4 < 10 THEN s$ = s$ + "0"
  21.                         s$ = s$ + LTRIM$(STR$(num4))
  22.                         IF num5 < 10 THEN s$ = s$ + "0"
  23.                         s$ = s$ + LTRIM$(STR$(num5))
  24.                         IF num6 < 10 THEN s$ = s$ + "0"
  25.                         s$ = s$ + LTRIM$(STR$(num6))
  26.                         n = n + 1
  27.                         Combos(n) = VAL(s$)
  28.                     NEXT
  29.                 NEXT
  30.             NEXT
  31.         NEXT
  32.     NEXT
  33.  

Note the total percent completion isn't correct -- it's mainly there to give you something to look at while its generating combinations for you.  Our numbers start with 1 (and whatever digits next)  and percentages start at 0%, and 1/55 isn't going to give us a 0% completion starting point.  It can be corrected easily enough, but I figure the program is slow enough already just generating all the possible combinations and printing what it does to the screen -- no need for it to do any more math than necessary.

From start to finish, I guesstimate that this will take about an hour to generate all the possible combinations and store them in memory for you, so if you're actually going to use these values for some lotto program, then you may want to save them in a file as I did originally so all you have to do is access it to get the corresponding combination.  (For example, a random access file of 50 million values, and then you just need a single RND call to look at that record and see what all 6 numbers would be.)

Memory requirements, in this case, is 50 million records * 8 bytes per record (I'm using an integer64 to hold the values), so about 400MB (plus a little internal overhead) to hold them all in memory, so keep that in mind for whatever else you might need to do with the rest of your program.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #11 on: March 28, 2019, 01:34:27 pm »
Steve, using your first listing, I had a file written in about 10 minutes!

But access to the end of the file was tricky, NotePad++ kept crashing when I do something like Crtl + End or GO line number near the end.

So I tried access by INPUT, way to slow!
So I had to figure out Random access again, it's been years! Got it fast!
Code: QB64: [Select]
  1. 'since Notepad++ dies when I try to access lines past 50 million but it does say there are the right amount of lines
  2. SCREEN _NEWIMAGE(600, 700, 32)
  3. _SCREENMOVE 300, 20
  4.  
  5.  
  6. ''this method way too slow
  7. 'OPEN "6 Combos from 60 Numbers.txt" FOR INPUT AS #1  'I changed name of file from temp.txt
  8. 'WHILE NOT EOF(1)
  9. '    LINE INPUT #1, fline$
  10. '    i = i + 1
  11. '    IF i > 50063830 THEN
  12. '        PRINT i, fline$
  13. '    ELSEIF i < 40 THEN 'chck a print
  14. '        PRINT i, fline$
  15. '    ELSE
  16. '        IF i MOD 1000000 = 0 THEN
  17. '            CLS
  18. '            PRINT i \ 1000000; "millions lines"
  19. '        END IF
  20. '    END IF
  21. '    '_LIMIT 1000
  22. 'WEND
  23.  
  24. TYPE record
  25.     f1 AS STRING * 17
  26.     crlf AS STRING * 2
  27. DIM rec AS record
  28. OPEN "6 Combos from 60 Numbers.txt" FOR RANDOM AS #1 LEN = 19
  29. fl = LOF(1) / 19 'this is giving number too small, oh forgot the 5 commas
  30. FOR i = fl - 30 TO fl
  31.     GET #1, i, rec
  32.     PRINT i, rec.f1
  33.  
  34.  
50063860 Combos of 6 for 60 elements.PNG
« Last Edit: March 28, 2019, 03:00:16 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Mega sena database
« Reply #12 on: March 28, 2019, 03:57:42 pm »
Bplus,

To make use of that sequential text file, I’d suggest using SEEK to go directly to the proper record.

Each record is a fixed size:  2 digits for each of the six numbers, five digits for the comma, 2 digits for the CRLF at the end of the line (for files created in WINDOWS, else CRLF is 1 digit).

19 characters per result, and we start at byte 1 for file access, instead of 0, which gives us:

RecordPosition = (RecordNumber - 1) * 19 + 1

First Record starts at byte (1 - 1) * 19 + 1 = 1
Second Record starts at byte (2 - 1) * 19 + 1 = 20

So to go directly to a record in that file:

OPEN “temp.txt” FOR INPUT AS #1
.... stuff

SEEK #1, (RecordNumber - 1) * 19 + 1
FOR i = 1 TO 6
    INPUT Ball(i)
NEXT

.... CLOSE
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Mega sena database
« Reply #13 on: March 28, 2019, 04:20:47 pm »
Thanks Steve, I did not know that SEEK works for files Opened for Input.

But I am happy to have successfully reviewed Random access.

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Mega sena database
« Reply #14 on: March 28, 2019, 07:07:04 pm »
Good night,
I am very grateful to bplus and SMcNeill for responding and creating ways to generate the combinations.

Like bplus, I used the first listing, I had a file written in about 10 minutes!
I got wheel bplus Random Access, now for the SMcNeill query

OPEN "temp.txt" FOR INPUT AS # 1
.... stuff

SEEK # 1, (RecordNumber - 1) * 19 + 1
FOR i = 1 TO 6
     INPUT Ball (i)
NEXT
CLOSE

I gave a mistake
I ask SMcNeill, is your code incomplete?

Following is an image of the error,
I will be very grateful if you can send the code for consultation
Bplus.jpg
* Bplus.jpg (Filesize: 337.91 KB, Dimensions: 1039x983, Views: 306)
SMcNeill.jpg
* SMcNeill.jpg (Filesize: 124.98 KB, Dimensions: 1015x997, Views: 312)
« Last Edit: March 28, 2019, 07:15:53 pm by carloscordeiro »