I have an array of 1000 numbers, randomly generated. 10 of those numbers must be between 0-9 (including 0 and 9), and 10 of those numbers must be between 991 and 1000 (including 991 and 1000). This is what I came up with:
arr = []
980.times do
arr << (11..989).to_a.sample
end
arr2 = []
10.times do
arr2 << rand(10)
end
arr3 = []
10.times do
arr3 << (990..1000).to_a.sample
end
arr4 = []
arr4 = arr + arr2 + arr3
arr4.shuffle
Is there a more elegant way to do this in ruby?