1

##### Scripting Languages / Re: Quick Basic Efficiency Assistance

« Last post by**Reyth**on

*February 15, 2017, 07:35:02 AM*»

I see this post was read 8 times. I entered my hydro-powered meditation chamber this morning (the shower) thinking about this problem. The solution instantly came to me! Random was no longer my friend! Why not just dispense with the array and output all combinations directly to a file? I then reasoned at the computer that I could sort out the "shadows" by simply insuring that at least 1 number remains below 7.

Here is the code that resulted from my hydro meditation:

5 OPEN "6_Output_Test.txt" FOR OUTPUT AS #1

10 FOR i = 1 TO 12: FOR j = 1 TO 12: FOR k = 1 TO 12: FOR l = 1 TO 12: FOR m = 1 TO 12: FOR n = 1 TO 12

20 IF i = j OR i = k OR i = l OR i = m OR i = n THEN 50

21 IF j = k OR j = l OR j = m OR j = n THEN 50 'advance loop

22 IF k = l OR k = m OR k = n THEN 50 'advance loop

23 IF l = m OR l = n THEN 50 'advance loop

24 IF m = n THEN 50 'advance loop

40 PRINT #1, i, j, k, l, m, n: c = c + 1: LOCATE 1, 1: PRINT c

50 NEXT n, m, l, k, j, i: CLOSE #1

60 OPEN "6_output_Test.txt" FOR INPUT AS #1

70 OPEN "6_Output_Sort_Test.txt" FOR OUTPUT AS #2

80 FOR i = 1 TO 12: FOR j = 1 TO 12: FOR k = 1 TO 12: FOR l = 1 TO 12: FOR m = 1 TO 12: FOR n = 1 TO 12

90 INPUT #1, a, b, c, d, e, f

100 IF a < 7 OR b < 7 OR c < 7 OR d < 7 OR e < 7 OR f < 7 THEN PRINT #2, a, b, c, d, e, f: cc = cc + 1: LOCATE 1, 1: PRINT cc

110 NEXT n, m, l, k, j, i

WARNING: This code will generate a "read beyond file end" error upon completion. Just ignore it and close out; all the data is in the file.

664561 duplicate free combinations are now in my possession! I am ALL POWERFUL!! MUWAHAHAAHAHAHAAHAHAAH!

Here is the code that resulted from my hydro meditation:

5 OPEN "6_Output_Test.txt" FOR OUTPUT AS #1

10 FOR i = 1 TO 12: FOR j = 1 TO 12: FOR k = 1 TO 12: FOR l = 1 TO 12: FOR m = 1 TO 12: FOR n = 1 TO 12

20 IF i = j OR i = k OR i = l OR i = m OR i = n THEN 50

21 IF j = k OR j = l OR j = m OR j = n THEN 50 'advance loop

22 IF k = l OR k = m OR k = n THEN 50 'advance loop

23 IF l = m OR l = n THEN 50 'advance loop

24 IF m = n THEN 50 'advance loop

40 PRINT #1, i, j, k, l, m, n: c = c + 1: LOCATE 1, 1: PRINT c

50 NEXT n, m, l, k, j, i: CLOSE #1

60 OPEN "6_output_Test.txt" FOR INPUT AS #1

70 OPEN "6_Output_Sort_Test.txt" FOR OUTPUT AS #2

80 FOR i = 1 TO 12: FOR j = 1 TO 12: FOR k = 1 TO 12: FOR l = 1 TO 12: FOR m = 1 TO 12: FOR n = 1 TO 12

90 INPUT #1, a, b, c, d, e, f

100 IF a < 7 OR b < 7 OR c < 7 OR d < 7 OR e < 7 OR f < 7 THEN PRINT #2, a, b, c, d, e, f: cc = cc + 1: LOCATE 1, 1: PRINT cc

110 NEXT n, m, l, k, j, i

WARNING: This code will generate a "read beyond file end" error upon completion. Just ignore it and close out; all the data is in the file.

664561 duplicate free combinations are now in my possession! I am ALL POWERFUL!! MUWAHAHAAHAHAHAAHAHAAH!