Created
May 31, 2011 08:05
-
-
Save huobazi/1000137 to your computer and use it in GitHub Desktop.
双色球选号器
This file contains hidden or 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
def rand_array(arr) | |
rand_arr = [] | |
temp_arr = [] | |
s = arr.size-1 | |
for i in 0..s | |
r=rand(s+1) | |
if temp_arr[r] != 1 | |
rand_arr.push(arr[r]) | |
temp_arr[r] = 1 | |
else | |
redo | |
end | |
end | |
return rand_arr | |
end | |
result_red = [] | |
for item in 1..33 | |
result_red.push(item) | |
end | |
print rand_array( result_red).slice(0,6).join(',') | |
print '-------' | |
result_blue = [] | |
for item_x in 1..16 | |
result_blue.push(item_x) | |
end | |
print rand_array( result_blue).slice(0,1).join(',') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment