Created
October 8, 2012 07:53
-
-
Save Arakaki-Yuji/3851256 to your computer and use it in GitHub Desktop.
making array that filled the numbers, these are random and uniq.
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 uniq_rand_ary(size) | |
ary1 = [] | |
ary2 = [] | |
size.times do |i| | |
ary1 << i | |
end | |
count = ary1.size | |
count.times do |c| | |
ary2 << ary1.delete_at(rand(count - c)) | |
end | |
return ary2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
uniq_rand_ary(size) can use making a array that are filled the numbers
size of array is first argument.
first argument must be Numeric