Created
November 13, 2012 22:00
-
-
Save ninthdrug/4068703 to your computer and use it in GitHub Desktop.
Rock Paper Scissors in Scala
This file contains 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
// 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