Skip to content

Instantly share code, notes, and snippets.

@LisaBee224
Last active April 15, 2016 03:53
Show Gist options
  • Save LisaBee224/63cef5c25ee7b82a9dfbb7aa6ee90f9d to your computer and use it in GitHub Desktop.
Save LisaBee224/63cef5c25ee7b82a9dfbb7aa6ee90f9d to your computer and use it in GitHub Desktop.
def shuffle(array)
comp_array = array.dup
random_nums = []
until random_nums.length == array.length
j = rand(array.length)
if !random_nums.include?(j)
random_nums << j
end
end
count = 0
array.each do |elm, index|
array[count] = comp_array[random_nums[count]]
count +=1
end
p array
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment