10-25-2004, 03:24 AM
I would appreciate help on this. I'm stuck
What I'm trying to do is record the number of "hits" or matches, in order,
between two sets of numbers.
The first set is always in numerical order 1,2,3,4,5,6
The second set is a set of non-repeating random numbers. It can be a larger
range, say 1 through 9.
Example:
1,2,3,4,5,6 (first set) 1 through 6
1,4,8,3,5,7 (second set) random number drawn. 1 through 9 (non-repeating
i.e. each must all be different from all the others)
The program should spit out "2" as the result. Because there are two
matches.
1-1 match
2-4 no match
3-8 no match
4-3 no match
5-5 match
6-7 no match
Below is what I got so far but I can't get the program to compare one from
set 1 against one from set 2.
Thanks
CLS
CONST itema = 6 'number of draws per game. Allows upto to 200
maximum
DIM a(itema)
match=0
cntr = 0
FOR num = 1 TO itema
LET a(num) = num
NEXT num
PRINT : PRINT "initial draw:";
FOR num = 1 TO itema
PRINT a(num);
NEXT num
REM ####################################################################
CONST itemb = itema
DIM b(itemb)
RANDOMIZE TIMER ' must be outside loop
50
FOR numb = 1 TO itemb
LET b(numb) = INT(9 * RND) + 1
NEXT numb
REM ############### prevents duplicate random numbers #################
FOR OUTER = 1 TO itemb - 1
FOR INNER = OUTER + 1 TO itemb
IF b(OUTER) < b(INNER) THEN GOTO NOCHANGE
IF b(OUTER) = b(INNER) THEN GOTO 50 ' prevents duplicate numbers
' SWAP b(OUTER), b(INNER) ' rem out. Do not want to sort random
numbers
NOCHANGE:
NEXT INNER
NEXT OUTER
REM ##############################################################
PRINT : PRINT "random draw:";
FOR numb = 1 TO itema
PRINT b(numb);
NEXT numb
PRINT : PRINT "number of matches is "; match
What I'm trying to do is record the number of "hits" or matches, in order,
between two sets of numbers.
The first set is always in numerical order 1,2,3,4,5,6
The second set is a set of non-repeating random numbers. It can be a larger
range, say 1 through 9.
Example:
1,2,3,4,5,6 (first set) 1 through 6
1,4,8,3,5,7 (second set) random number drawn. 1 through 9 (non-repeating
i.e. each must all be different from all the others)
The program should spit out "2" as the result. Because there are two
matches.
1-1 match
2-4 no match
3-8 no match
4-3 no match
5-5 match
6-7 no match
Below is what I got so far but I can't get the program to compare one from
set 1 against one from set 2.
Thanks
CLS
CONST itema = 6 'number of draws per game. Allows upto to 200
maximum
DIM a(itema)
match=0
cntr = 0
FOR num = 1 TO itema
LET a(num) = num
NEXT num
PRINT : PRINT "initial draw:";
FOR num = 1 TO itema
PRINT a(num);
NEXT num
REM ####################################################################
CONST itemb = itema
DIM b(itemb)
RANDOMIZE TIMER ' must be outside loop
50
FOR numb = 1 TO itemb
LET b(numb) = INT(9 * RND) + 1
NEXT numb
REM ############### prevents duplicate random numbers #################
FOR OUTER = 1 TO itemb - 1
FOR INNER = OUTER + 1 TO itemb
IF b(OUTER) < b(INNER) THEN GOTO NOCHANGE
IF b(OUTER) = b(INNER) THEN GOTO 50 ' prevents duplicate numbers
' SWAP b(OUTER), b(INNER) ' rem out. Do not want to sort random
numbers
NOCHANGE:
NEXT INNER
NEXT OUTER
REM ##############################################################
PRINT : PRINT "random draw:";
FOR numb = 1 TO itema
PRINT b(numb);
NEXT numb
PRINT : PRINT "number of matches is "; match