Created
September 7, 2010 13:05
-
-
Save yitsushi/568289 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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