Title: A new random generator Post by: Smurfy on February 20, 2008, 05:09:30 PM Well, I need to come up with another random number generator. Here's the one I have.
Code: CLS but I need one that takes two arrays and you leave one unpopulated for now but with the other you generate a random number lets say five you assign that to position one in array A and in array B you go over to the fifth position and change the zero there to a one, then you generate a seven and you assign that to position two in array A and in array B you change the zero in the seventh position to a one and so on, and if you generate a random number in Array A that has already come up and its position in array b is assigned a one instead of a zero you erase that number from array A and reassign it with a new number. i need this one so i can compare the two to see which one is more random. I got the other one pretty easily but I don't quite know how to start this oneINPUT "How many random numbers would you like to generate"; X DIM A(X) AS INTEGER FOR C = 1 TO X A(C) = C NEXT C RANDOMIZE TIMER FOR SWITCH = 1 TO 10 FOR C = 1 to X B = INT(X * RND (1) + 1) SWAP A(C), A(B) NEXT C NEXT SWITCH FOR C = 1 TO X PRINT A(C) NEXT C OPEN "rnd.csv" FOR OUTPUT AS #1' This just makes it so you can put it in a spreadsheet and test it for no repeats" FOR D = 1 TO X PRINT #1, A(D) NEXT D CLOSE #1 Title: Re: A new random generator Post by: Mac on March 05, 2008, 08:07:27 AM I don't quite know how to start this one Code: CLS INPUT "How many random numbers would you like to generate"; X DIM A(X) AS INTEGER DIM B(X) AS INTEGER FOR C = 1 TO X N = 1 + INT(RND * X) PRINT N NEXT C Then replace PRINT N to code which does what you said. Mac Title: Re: A new random generator Post by: Smurfy on March 05, 2008, 10:42:06 AM Thank you, I'll see where that takes me.
