Skip to content

Instantly share code, notes, and snippets.

@JonCrawford
Created July 29, 2010 00:30
Show Gist options
  • Save JonCrawford/496863 to your computer and use it in GitHub Desktop.
Save JonCrawford/496863 to your computer and use it in GitHub Desktop.
def random_elements(arr, num_items)
el = arr.dup
results = []
num_items.times{results << el.delete(el[rand(el.size)])}
return results
end
random_elements((1..10000).to_a, 25)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment