Hello there
I am writing a program to generate 39 combinations of numbers into rows of 5 each. I managed to do this with the FOR ...NEXT function. I also have a list of numbers I want to compare it to.These are 600 lines of numbers with 5 numbers on each line.If a generated number matches 5 numbers in a line in the database,it will ignore this and GOTO the next generated number until an unmatched number does not come up,in this case it prints to the screen and is counted The problem is this database of numbers is too big to be added to the program code with the DATA and READ statements,so I have to store the date base in a different file and open it to read from it. I have a problem with the program reading the file using the IF ,Then functions and the AND OR functions to compare the data it does not seem to be working.
Here's how the code looks like:
[highlight #3465A4]
FOR a = 1 TO 35
FOR b = 2 TO 36
FOR c = 3 TO 37
FOR d = 4 TO 38
FOR e = 5 to 39
IF a = b OR a > b THEN 493
IF b = c OR b > c THEN 492
IF c = d OR c > d THEN 491
IF d = e OR 8d > e THEN 490
OPEN "list.txt" FOR INPUT AS #1
DO UNTIL EOF(1)
INPUT #1, aa,bb,cc,dd,ee
IF (aa = a) AND (bb = b) AND (cc = c) AND (dd = d) AND (ee = e) THEN GOTO 299
GOTO 300
299 EXIT DO
CLOSE #1
GOTO 489
300 LOOP
CLOSE #1
301
tot = tot + 1
print a;b;c;d;e
489 NEXT t
490 NEXT e
491 NEXT d
492 NEXT c
493 NEXT b
494 NEXT a
[/highlight]
What am I doing wrong?
Is there a better way to write the program?
Is there a way to get past the out of memory issue with Qbasic?
Ta
Mick
I am writing a program to generate 39 combinations of numbers into rows of 5 each. I managed to do this with the FOR ...NEXT function. I also have a list of numbers I want to compare it to.These are 600 lines of numbers with 5 numbers on each line.If a generated number matches 5 numbers in a line in the database,it will ignore this and GOTO the next generated number until an unmatched number does not come up,in this case it prints to the screen and is counted The problem is this database of numbers is too big to be added to the program code with the DATA and READ statements,so I have to store the date base in a different file and open it to read from it. I have a problem with the program reading the file using the IF ,Then functions and the AND OR functions to compare the data it does not seem to be working.
Here's how the code looks like:
[highlight #3465A4]
FOR a = 1 TO 35
FOR b = 2 TO 36
FOR c = 3 TO 37
FOR d = 4 TO 38
FOR e = 5 to 39
IF a = b OR a > b THEN 493
IF b = c OR b > c THEN 492
IF c = d OR c > d THEN 491
IF d = e OR 8d > e THEN 490
OPEN "list.txt" FOR INPUT AS #1
DO UNTIL EOF(1)
INPUT #1, aa,bb,cc,dd,ee
IF (aa = a) AND (bb = b) AND (cc = c) AND (dd = d) AND (ee = e) THEN GOTO 299
GOTO 300
299 EXIT DO
CLOSE #1
GOTO 489
300 LOOP
CLOSE #1
301
tot = tot + 1
print a;b;c;d;e
489 NEXT t
490 NEXT e
491 NEXT d
492 NEXT c
493 NEXT b
494 NEXT a
[/highlight]
What am I doing wrong?
Is there a better way to write the program?
Is there a way to get past the out of memory issue with Qbasic?
Ta
Mick