Skip to content

Instantly share code, notes, and snippets.

@yitsushi
Created September 7, 2010 13:05
Show Gist options
  • Save yitsushi/568289 to your computer and use it in GitHub Desktop.
Save yitsushi/568289 to your computer and use it in GitHub Desktop.
class Array
def randomize
self.sort {rand(self.length / 2)-1}
end
def randomize!
self.sort! {rand(self.length / 2)-1}
end
end
n=5
a = (1..95).to_a
puts "Lottery numbers: (^_^)"
p a.randomize[0..(n-1)]
p a.randomize[0..(n-1)]
p a.randomize[0..(n-1)]
p a.randomize[0..(n-1)]
p a.randomize[0..(n-1)]
p a.randomize[0..(n-1)]
p a.randomize[0..(n-1)]
# Output:
#
# Lottery numbers: (^_^)
# [31, 67, 95, 52, 83]
# [21, 44, 95, 41, 12]
# [37, 59, 95, 53, 72]
# [43, 59, 95, 55, 3]
# [34, 18, 94, 2, 95]
# [95, 59, 48, 60, 19]
# [82, 95, 48, 22, 60]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment