But when it arrives at a certain point, the program will no longer check the number generated in the database.
When 6 unique 2 digit numbers are drawn, the drawing is concluded.Yikes! that seems complicated.
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.
If you want a list of all the possible combinations, then what you want is something like the following:Code: QB64: [Select]
PRINT "Calculating..."
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]
01,02,03,04,05,06 01,02,03,04,05,07 01,02,03,04,05,08 01,02,03,04,05,09 01,02,03,04,05,10 01,02,03,04,05,11 01,02,03,04,05,12 01,02,03,04,05,13 01,02,03,04,05,14 01,02,03,04,05,15 01,02,03,04,05,16 01,02,03,04,05,17 01,02,03,04,05,18 01,02,03,04,05,19 01,02,03,04,05,20 01,02,03,04,05,21 01,02,03,04,05,22 01,02,03,04,05,23 01,02,03,04,05,24 01,02,03,04,05,25 01,02,03,04,05,26 01,02,03,04,05,27 01,02,03,04,05,28 01,02,03,04,05,29 01,02,03,04,05,30 01,02,03,04,05,31 01,02,03,04,05,32 01,02,03,04,05,33 01,02,03,04,05,34 01,02,03,04,05,35 01,02,03,04,05,36 01,02,03,04,05,37 01,02,03,04,05,38 01,02,03,04,05,39 01,02,03,04,05,40 01,02,03,04,05,41 01,02,03,04,05,42 01,02,03,04,05,43 01,02,03,04,05,44 01,02,03,04,05,45 01,02,03,04,05,46 01,02,03,04,05,47 01,02,03,04,05,48 01,02,03,04,05,49 01,02,03,04,05,50 01,02,03,04,05,51 01,02,03,04,05,52 01,02,03,04,05,53 01,02,03,04,05,54 01,02,03,04,05,55 01,02,03,04,05,56 01,02,03,04,05,57 01,02,03,04,05,58 01,02,03,04,05,59 01,02,03,04,05,60 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.
bplus, please, please, tell me what comes before .... dot
OPEN "temp.txt" FOR INPUT AS # 1
.... stuff
SEEK # 1, (RecordNumber - 1) * 19 + 1
FOR i = 1 TO 6
INPUT Ball (i)
NEXT
CLOSE
Thank you very much for your help, and for SMcNeill.
CarlosCordeiro.
bplus, please, please, tell me what comes before .... dot
OPEN "temp.txt" FOR INPUT AS # 1
.... stuff
SEEK # 1, (RecordNumber - 1) * 19 + 1
FOR i = 1 TO 6
INPUT Ball (i)
NEXT
CLOSE
Thank you very much for your help, and for SMcNeill.
CarlosCordeiro.
Good night, Steve.
Not wanting to be Inconvenient, could you exemplify how do I end part of the sequence and start over again where She stopped? Let's say I want to populate the temp.txt file with Intervals without it losing its order.
I mean, insert 1 million today, then 2 million more, until you reach 50 million.
It is very important to me.
Appreciate.
PRINT "Calculating..."
OPEN "temp.txt" FOR OUTPUT AS #1
FOR num1 = 1 TO 55
LOCATE 5, 3: PRINT num1,
FOR num2 = num1 + 1 TO 56
LOCATE 5, 5: PRINT num2,
FOR num3 = num2 + 1 TO 57
LOCATE 5, 7: PRINT num3,
FOR num4 = num3 + 1 TO 58
LOCATE 5, 9: PRINT num4,
FOR num5 = num4 + 1 TO 59
LOCATE 5, 11: PRINT num5,
FOR num6 = num5 + 1 TO 60
LOCATE 5, 13: PRINT num6
s$ = LTRIM$(STR$(num1)) + ","
IF num1 < 10 THEN s$ = "0" + s$
IF num2 < 10 THEN s$ = s$ + "0"
s$ = s$ + LTRIM$(STR$(num2)) + ","
IF num3 < 10 THEN s$ = s$ + "0"
s$ = s$ + LTRIM$(STR$(num3)) + ","
IF num4 < 10 THEN s$ = s$ + "0"
s$ = s$ + LTRIM$(STR$(num4)) + ","
IF num5 < 10 THEN s$ = s$ + "0"
s$ = s$ + LTRIM$(STR$(num5)) + ","
IF num6 < 10 THEN s$ = s$ + "0"
s$ = s$ + LTRIM$(STR$(num6))
PRINT #1, s$
NEXT
NEXT
NEXT
NEXT
NEXT
NEXT
I have nothing to do with this, but why again?
Thank you very much, that's exactly what I want Jack. Write 1 million lottery numbers in a text file and then suspend the operation, so the next few days pick up where you left off and add another million numbers a day until you finish.
Thanks again to bplus. The code resumes where it stopped, but does not continue to count 1 million, it returns to the beginning.
CarlosCordeiro
Bplus, on day 2 it will resume the sequence of 1,2,3,4,5,6. If the code could start from 01,04,13,23,30,59. So there would be no need to go back to the beginning. My intention would be this.
I'm sorry if I'm getting inconvenient
CarlosCordeiro
If Mr. FellippeHeitor does not feel uncomfortable. I wanted to ask for a final help from bplus or Steve.
(...)
I reiterate the apology to Mr. FellippeHeitor if he feels uncomfortable.
I have nothing to do with this, but why again?
Mr. FellippeHeitoris better than gold!
Easiest fix:
First, look to see if the file exists. If not, all the loops numbers start at 1. If it does, read the last set of numbers into the program and continue:Code: QB64: [Select]
num6start = num6start + 1
Now change the loops to start with that start variable value:
FOR num1 = num1start to 55
FOR num2 = num2start to 56
.....so on for 3,4,5,6
Then after the NEXT statements, reset the start values to their proper value:
NEXT num6
num6start = num5 + 1
NEXT num5
num5start = num4 + 1
NEXT num4
num4start = num3 + 1
....and so on.
Add an exit condition in the middle loop after the PRINT #1 statement such as:
IF INKEY$ <> “” THEN END
Then you can build, stop, and resume building that list whenever you want.
Holy ship! Steve's Append Method is a disaster, it does not end like this:
Going back to fool proof method!
Slight correction to remove some duplicate values from our list generation. It's a little bit trickier than I first imagined, but I think this does it properly for us:Code: QB64: [Select]
num6start = num6start + 1 PRINT "Resuming count from old file." num1start = 1 num2start = 2 num3start = 3 num4start = 4 num5start = 5 num6start = 6 PRINT "Generating values in new 'temp.txt' file." PRINT "Calculating further values..." PRINT "Press <ANY KEY> to stop." num6start = num5 + 1 num5start = num4 + 1 num4start = num3 + 1 num3start = num2 + 1 num2start = num1 + 1
Hello bplus
Good night
Should I win the prize? Of course I will remember you bplus. You and Steve deserve it, for dedicating yourself to a newcomer like me. Just send the account number. :)
I am not trying to rewrite the data file.
I was trying to put in the only code, the two codes that you and Steve created for me.
The code that generates the combinations and the code that read the combinations.
In a single code, the two codes together into one.
With a Loop, more with the IF INKEY $ <> "" THEN END in the end for when I want to leave.
I ran the latter and it made a mistake on the line that is Seek
CarlosCordeiro
Really bplus, there's a little flaw in Steve's last code, but I think he'll be fixing it.
Another question I have, is it possible to put a line with some command to show the number of combinations registered in the temp.txt file?
Hey Steve! I think you got it. Nice, and not terribly complicated.
I had given up after a couple more attempts tonight.
If the last edit was -17, I did get that.
I ran your code first uninterrupted. Right record counts and a couple checks in file like 1000000th
Then ran your code with like 6 interruptions and then let it run to finish, last lines looked right, 1000000th and 2000000th were good.
OH! I wonder if the -17 was why I was getting weird results. I was going on -18... :)
Last edit was to fix the -17 to the proper -18:Code: QB64: [Select]
'Instead, the file ends with a EOF single byte character, so back up 18 spots instead of 19 'I'm such an idiot not to notice the difference! GAHHHH!!!
The reason why it worked for 1,000,000 and 2,000,000, is the values returned:
01,04,13,23,30,60
01,07,16,42,44,26
If those were the last records written, and we backed up 17 spots from the end of file, what'd we retrieve would be:
01,04,13,23,30,60
01,07,16,42,44,26
Cutting off the 0 in these instances doesn't break anything, but it does once we end up getting to a value such as:
11,04,13,23,30,60
Not much difference between 01 and 1, but there's a huge difference between 11 and 1. That single byte was throwing everything off, and I just couldn't seem to notice where the glitch was! :)
WITH ONE GLARING EXCEPTION:
The last record doesn't have a CRLF at the end of it. It has an EOF (CHR$(26) character, I think) character at the end of it -- which means we don't back up 19 spots from the end to get our last written value... NOR do we back up 17 spots from the end to get our last written values...
We back up EIGHTEEN bytes from the end to get our last values!!
GAH!! I feel like such an idiot now that I've sorted out what my biggest glitch was. I knew this. I just didn't think about it when writing the program and since the values are so large, I didn't do enough testing to catch the issue myself earlier...
So Steve, your head must be spinning as badly as mine when I see it was suppose to be -18 not -17. Yikes!