Skip to content

Instantly share code, notes, and snippets.

@ninthdrug
Created November 13, 2012 22:00
Show Gist options
  • Save ninthdrug/4068703 to your computer and use it in GitHub Desktop.
Save ninthdrug/4068703 to your computer and use it in GitHub Desktop.
Rock Paper Scissors in Scala
// rock paper scissors in scala
import scala.util.Random
def rockPaperScissors(): String = {
Random.nextDouble match {
case d if d < 1.0 / 3 => "rock"
case d if d < 2.0 / 3 => "paper"
case _ => "scissors"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment