Skip to content

Instantly share code, notes, and snippets.

@Arakaki-Yuji
Created October 8, 2012 07:53
Show Gist options
  • Save Arakaki-Yuji/3851256 to your computer and use it in GitHub Desktop.
Save Arakaki-Yuji/3851256 to your computer and use it in GitHub Desktop.
making array that filled the numbers, these are random and uniq.
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
@Arakaki-Yuji
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment