Last active
December 3, 2015 20:13
-
-
Save DickyT/20c2e063adb93a1a3923 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Procedure GenerateDraw ( n ) | |
INPUT: n, the length of the random array | |
OUTPUT: result_array, the array contains unique random integers of length n | |
result_array <- CREATE and array of length n | |
loop n times { | |
current_rand = 0 | |
check_pass = True | |
while current_rand == 0 or check_pass == False { | |
current_rand = GENERATE a random integer between 1 and 49 | |
for each each_int in result_array { | |
if each_int == current_rand { | |
check_pass = False | |
break | |
} | |
else { | |
check_pass = True | |
} | |
} | |
} | |
if check_pass == True { | |
ADD value current_rand to the end of array result_array | |
} | |
else { | |
throw new Exception("whatever") | |
} | |
} | |
return result_array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment