prismite Posted March 9, 2015 Posted March 9, 2015 Hi all! Is there a way to utilize this kind of code, but make it so that if the program happens to land on a repeat number it ignores it and reselects? For $n = 5 to 1 Step -1 $RandomNumber = RANDOM (1,10,1) If $RandomNumber = 1 then FUNC1 If $RandomNumber = 1 then FUNC2 If $RandomNumber = 1 then FUNC3 If $RandomNumber = 1 then FUNC4 ... Next
Herb191 Posted March 9, 2015 Posted March 9, 2015 One way... #include <Array.au3> Dim $aNumbers[1] For $i = 1 To 10 Step 1 $iArraySize = UBound($aNumbers) Do $RandomNumber = Random(1, 10, 1) _ArrayAdd($aNumbers, $RandomNumber) $aNumbers = _ArrayUnique($aNumbers, 0, 1) Until $iArraySize < UBound($aNumbers) ConsoleWrite($RandomNumber & @CRLF) Next
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now