Skip to content

Instantly share code, notes, and snippets.

@migue
Last active December 12, 2015 01:18
Show Gist options
  • Save migue/4690167 to your computer and use it in GitHub Desktop.
Save migue/4690167 to your computer and use it in GitHub Desktop.
Small script to choose a random element in a list. It is used to raffle conference tickets among the MadridJUG community members
import scala.util.Random
def winner(members:List[String]):String = {
new Random(System.currentTimeMillis()).shuffle(members).head
}
// write the names of all the members involved in the raffle
val qcon = List("Jorge Baez", "Daniel Jiménez", "Gonzalo Gómez", "Jorge Nota", "Jose Ignacio Dominguez", "Daniel Hernández", "Manuel Carrasco")
println("The winner of the QCon London ticket is " + winner(qcon))
val devoxx = List("Daniel Jiménez", "Gonzalo Gómez", "Jorge Nota", "Jose Ignacio Dominguez", "Daniel Hernández", "Manuel Carrasco", "Jorge Baez")
println("The winner of the Devoxx UK ticket is " + winner(devoxx))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment