EndGame2013 Posted December 2, 2012 Share Posted December 2, 2012 (edited) How do I select a random number between a min and a max, and then after picking that number select another random number between the same min/max excluding the first number I picked? Example: I want to select 5 random numbers between 1 and 12, and each selection can not be the same. If I select the number 6 the first time I do not want it to be possible to select the number 6 again. The only way I can see it being done is to compare the later results with the former results and if they are the same, run the random number generator again.. but then is it still truely random? I am no mathmatician so I have no idea... but it does need to be completely random. Does picking an already picked number, tossing it back, and selecting again count as random? Edited December 2, 2012 by SkybotGaming Link to comment Share on other sites More sharing options...
AZJIO Posted December 2, 2012 Share Posted December 2, 2012 My other projects or all Link to comment Share on other sites More sharing options...
EndGame2013 Posted December 2, 2012 Author Share Posted December 2, 2012 Perfect, thanks. Link to comment Share on other sites More sharing options...
czardas Posted December 3, 2012 Share Posted December 3, 2012 (edited) If you require the full range of numbers between a max and min value to be arranged in random order then you could also do something like this: #include <Array.au3> _Example() Func _Example() Local $aArray[100] For $i = 0 to 99 $aArray[$i] = $i Next _ArrayShuffle($aArray) _ArrayDisplay($aArray) EndFunc Func _ArrayShuffle(ByRef $aArray) If IsArray($aArray) = 0 Or UBound($aArray, 0) > 1 Then Return SetError (1) Local $vTemp, $r, $iBound = UBound($aArray) -1 For $i = 0 To $iBound $r = Random(0, $iBound, 1) $vTemp = $aArray[$i] $aArray[$i] = $aArray[$r] $aArray[$r] = $vTemp Next EndFunc Edited December 3, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
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