Skip to content

Instantly share code, notes, and snippets.

@ready4god2513
Created June 14, 2013 20:55
Show Gist options
  • Save ready4god2513/5785203 to your computer and use it in GitHub Desktop.
Save ready4god2513/5785203 to your computer and use it in GitHub Desktop.
The winners from the A is for Array 5 book giveaway!
# Add all of our contestants to an array.
# We will assign the array to a variable called contestants
# A variable lets us access the array later.
contestants = [
"Krystyna Marie Wood",
"Wissam Ali-Ahmad",
"Adrian Brightmoore",
"Diana Hall",
"Jonathan Zee",
"Todd Guerra",
"Melanie Reed",
"Lindsey Yoo",
"Rebecca Hanan",
"Karissa Furze",
"Michelle Moorehead Belmont",
"Shane Cammell",
"Jan Carpentier",
"Jay Murasaki",
"David Haddon",
"Kyle Sutherland",
"David Abbott",
"Nathan L. Ross",
"Jason Clarke",
"Michael Smith",
"Sara Sutherland",
"Christine McCall Schuette",
"Bethany Scofield"
]
# This makes sure that we don't have any duplicates
contestants.uniq!
# Now scramble the order of the contestants.
contestants.shuffle!
# Now we should have a random order of the names in the array.
# So now we can just get the first 5 elements (people) from the array.
# Those people are going to be the winner of the contest.
# This will output the names of our 5 winners!
puts "# WINNERS - "
puts contestants.first(5).map { |person| "# #{person}" }
# After running this code, here are the results-
# WINNERS -
# Lindsey Yoo
# Karissa Furze
# Todd Guerra
# Jay Murasaki
# Wissam Ali-Ahmad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment