Skip to content

Instantly share code, notes, and snippets.

@huobazi
Created May 31, 2011 08:05
Show Gist options
  • Save huobazi/1000137 to your computer and use it in GitHub Desktop.
Save huobazi/1000137 to your computer and use it in GitHub Desktop.
双色球选号器
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