Rock paper scissors

Report a typo

Finish the program that implements the famous game Rock paper scissors. This is a game for two players where each selects "rock", "paper" or "scissors". Our program receives the players' choices as input lines: for the first player and for the second. If both select the same shape, the program prints draw , otherwise it prints who wins.

Sample Input 1:

rock
rock

Sample Output 1:

draw
Write a program in Scala 3
object RockPaperScissors extends App {
val gameMap = Map(
"rock" -> Map(
"paper" -> "second win",
??? -> "first win",
),
???
)

val first = scala.io.StdIn.readLine()
val second = scala.io.StdIn.readLine()

val set = Set(first, ???)

if (set.size == 1)
println("draw")
else {
val mappingForFirst = gameMap(first)
println(mappingForFirst(???))
}
}
___

Create a free account to access the full topic