Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Rock-Paper-Scissors-Lizard-Spock: Probability of Rajesh Beating Sheldon, Lecture notes of Discrete Mathematics

In this document, sheldon from 'the big bang theory' explains the rules of the extended version of the game rock-paper-scissors called rock-paper-scissors-lizard-spock to rajesh. They decide to play this game and determine the probability that rajesh beats sheldon. An example of input and output for the problem.

What you will learn

  • What is the game of Rock-Paper-Scissors-Lizard-Spock based on?
  • How does Sheldon explain the rules of Rock-Paper-Scissors-Lizard-Spock to Rajesh?
  • What is the probability that Rajesh beats Sheldon in the game of Rock-Paper-Scissors-Lizard-Spock?

Typology: Lecture notes

2021/2022

Uploaded on 09/12/2022

dylanx
dylanx 🇺🇸

4.7

(21)

287 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Rock-Paper-Scissors-Lizard-Spock
Daniel enjoys watching TV series. One of his favorite is "The Big Bang Theory". The main
characters of this series are: Sheldon – genius theoretical physicist, his friend Leonard – talented
experimental physicist, their attractive, blonde neighbor Penny, and also their friends an
aerospace engineer Howard and a particle astrophysicist Rajesh.
One time Rajesh tells Sheldon:
“I'll tell you what. How about we go rock-paper-scissors?”
“Ooh”, – Sheldon replies – “I don't think so. Anecdotal evidence suggests that in the game of
rock-paper-scissors, players familiar with each other will tie 75 to 80% of the time due to the
limited number of outcomes. I suggest rock-paper-scissors-lizard-Spock”.
“What?”
“It's very simple. Scissors cuts paper. Paper covers rock. Rock crushes lizard. Lizard poisons
Spock. Spock smashes scissors. Scissors decapitates lizard. Lizard eats paper. Paper disproves
Spock. Spock vaporizes rock. And as it always has, rock crushes scissors”.
“Okay, I think I got it”.
And the friends decided to play rock-paper-scissors-lizard-Spock. And we would determine what
the probability that Rajesh beats Sheldon in this game. We know the probabilities that any of the
friends choose any object in the game. Also we know that they play till two wins, so the winner of
the game is the person who first wins two rounds.
Input
The first line of input contains the number t - the number of tests. Next comes the description of t
tests. Each test case consists of two lines. The first line contains five integers RR, RSc, RP, RL,
RSp – the probabilities that Rajesh chooses rock, scissors, paper, lizard or Spock respectively.
The second line contains five integers SR, SSc, SP, SL, SSp – the probabilities that Sheldon
chooses rock, scissors, paper, lizard or Spock respectively. (Note: the order of the objects in the
input is rock, scissors, paper, lizard, Spock. The original problem is in Russian and we have
scissors before paper in Russian variant of the game. Otherwise the rules are the same.)
Constraints
1 <= t <= 500
0 <= RR, RSc, RP, RL, RSp <= 100, RR + RSc + RP + RL + RSp = 100
0 <= SR, SSc, SP, SL, SSp <= 100, SR + SSc + SP + SL + SSp = 100
Output
For each test case print the probability that Rajesh beats Sheldon in percent rounded to the
nearest integer.
Example
Input:
2
10 20 30 40 0
10 10 10 10 60
pf2

Partial preview of the text

Download Rock-Paper-Scissors-Lizard-Spock: Probability of Rajesh Beating Sheldon and more Lecture notes Discrete Mathematics in PDF only on Docsity!

Rock-Paper-Scissors-Lizard-Spock

Daniel enjoys watching TV series. One of his favorite is "The Big Bang Theory". The main characters of this series are: Sheldon – genius theoretical physicist, his friend Leonard – talented experimental physicist, their attractive, blonde neighbor Penny, and also their friends an aerospace engineer Howard and a particle astrophysicist Rajesh. One time Rajesh tells Sheldon: “I'll tell you what. How about we go rock-paper-scissors?” “Ooh”, – Sheldon replies – “I don't think so. Anecdotal evidence suggests that in the game of rock-paper-scissors, players familiar with each other will tie 75 to 80% of the time due to the limited number of outcomes. I suggest rock-paper-scissors-lizard-Spock”. “What?” “It's very simple. Scissors cuts paper. Paper covers rock. Rock crushes lizard. Lizard poisons Spock. Spock smashes scissors. Scissors decapitates lizard. Lizard eats paper. Paper disproves Spock. Spock vaporizes rock. And as it always has, rock crushes scissors”. “Okay, I think I got it”. And the friends decided to play rock-paper-scissors-lizard-Spock. And we would determine what the probability that Rajesh beats Sheldon in this game. We know the probabilities that any of the friends choose any object in the game. Also we know that they play till two wins, so the winner of the game is the person who first wins two rounds.

Input

The first line of input contains the number t - the number of tests. Next comes the description of t tests. Each test case consists of two lines. The first line contains five integers RR, RSc, RP, RL, RSp – the probabilities that Rajesh chooses rock, scissors, paper, lizard or Spock respectively. The second line contains five integers SR, SSc, SP, SL, SSp – the probabilities that Sheldon chooses rock, scissors, paper, lizard or Spock respectively. ( Note: the order of the objects in the input is rock, scissors, paper, lizard, Spock. The original problem is in Russian and we have scissors before paper in Russian variant of the game. Otherwise the rules are the same.)

Constraints

1 <= t <= 500 0 <= RR, RSc, RP, RL, RSp <= 100, RR + RSc + RP + RL + RSp = 100 0 <= SR, SSc, SP, SL, SSp <= 100, SR + SSc + SP + SL + SSp = 100

Output

For each test case print the probability that Rajesh beats Sheldon in percent rounded to the nearest integer.

Example

Input: 2 10 20 30 40 0 10 10 10 10 60

20 20 20 20 20 20 20 20 20 20 Output: 66 50