answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
eduard
2 years ago
15

Same rule: If both players spend the same number of coins, player 2 gains 1 coin. Off-by-one rule: If the players do not spend t

he same number of coins and the positive difference between the number of coins spent by the two players is 1, player 2 is awarded 1 coin. Off-by-two rule: If the players do not spend the same number of coins and the positive difference between the number of coins spent by the two players is 2, player 1 is awarded 2 coins. The following is an example of a game played with a starting value of 10 coins and a game length of 5 rounds
Engineering
1 answer:
Galina-37 [17]2 years ago
3 0

Answer:

Check the explanation

Explanation:

1 -

public int getPlayer2Move(int round)

{

  int result = 0;

 

  //If round is divided by 3

  if(round%3 == 0) {

      result= 3;

  }

  //if round is not divided by 3 and is divided by 2

  else if(round%3 != 0 && round%2 == 0) {

      result = 2;

  }

  //if round is not divided by 3 or 2

  else {

      result = 1;

  }

 

  return result;

}

2-

public void playGame()

{

 

  //Initializing player 1 coins

  int player1Coins = startingCoins;

 

  //Initializing player 2 coins

  int player2Coins = startingCoins;

 

 

  for ( int round = 1 ; round <= maxRounds ; round++) {

     

      //if the player 1 or player 2 coins are less than 3

      if(player1Coins < 3 || player2Coins < 3) {

          break;

      }

     

      //The number of coins player 1 spends

      int player1Spends = getPlayer1Move();

     

      //The number of coins player 2 spends

      int player2Spends = getPlayer2Move(round);

     

      //Remaining coins of player 1

      player1Coins -= player1Spends;

     

      //Remaining coins of player 2

      player2Coins -= player2Spends;

     

      //If player 2 spends the same number of coins as player 2 spends

      if ( player1Spends == player2Spends) {

          player2Coins += 1;

          continue;

      }

     

      //positive difference between the number of coins spent by the two players

      int difference = Math.abs(player1Spends - player2Spends) ;

     

      //if difference is 1

      if( difference == 1) {

          player2Coins += 1;

          continue;

      }

     

      //If difference is 2

      if(difference == 2) {

          player1Coins += 2;

          continue;

      }

     

     

  }

 

  // At the end of the game

  //If player 1 coins is equal to player two coins

  if(player1Coins == player2Coins) {

      System.out.println("tie game");

  }

  //If player 1 coins are greater than player 2 coins

  else if(player1Coins > player2Coins) {

      System.out.println("player 1 wins");

  }

  //If player 2 coins is grater than player 2 coins

  else if(player1Coins < player2Coins) {

      System.out.println("player 2 wins");

  }

}

You might be interested in
A railcar with an overall mass of 78,000 kg traveling with a speed vi is approaching a barrier equipped with a bumper consisting
sergij07 [2.7K]

Answer:

v₀ = 2,562 m / s  = 9.2 km/h

Explanation:

To solve this problem let's use Newton's second law

              F = m a = m dv / dt = m dv / dx dx / dt = m dv / dx v

              F dx = m v dv

We replace and integrate

            -β ∫ x³ dx = m ∫ v dv

            β x⁴/ 4 = m v² / 2

We evaluate between the lower (initial) integration limits v = v₀, x = 0 and upper limit v = 0 x = x_max

        -β (0- x_max⁴) / 4 = ½ m (v₀²2 - 0)

         x_max⁴ = 2 m /β   v₀²

         

Let's look for the speed that the train can have for maximum compression

         x_max = 20 cm = 0.20 m

         

         v₀ =√(β/2m)   x_max²

Let's calculate

          v₀ = √(640 106/2 7.8 104)    0.20²

          v₀ = 64.05  0.04

          v₀ = 2,562 m / s

          v₀ = 2,562 m / s (1lm / 1000m) (3600s / 1h)

          v₀ = 9.2 km / h

5 0
2 years ago
A platinum resistance temperature sensor has a resistance of 120 Ω at 0℃ and forms one arm of a Wheatstone bridge. At this tempe
oksian1 [2.3K]

Answer : 9.36ohms/ temperature

Explanation:

Expression for the variation of resistance of platinum with temperature

Rt= Ro(1+*t)

Rt= resistance @ t°C

Ro= resistance @ 0°C

*= temperature coefficient of resistance

Calculate the change in resistance by putting 120ohms for Ro,

0.0039/K for *

20°C for t

Using this formula:

Rt = Ro(1+*t)

Rt- Ro = Ro*t

= (120ohms)(0.0039/K)(20°C)

= 9.36ohms/K

8 0
2 years ago
A plate of an alloy steel has a plane-strain fracture toughness of 50 MPa√m. If it is known that the largest surface crack is 0.
Ivahew [28]

Answer:

option B is correct. Fracture will definitely not occur

Explanation:

The formula for fracture toughness is given by;

K_ic = σY√πa

Where,

σ is the applied stress

Y is the dimensionless parameter

a is the crack length.

Let's make σ the subject

So,

σ = [K_ic/Y√πa]

Plugging in the relevant values;

σ = [50/(1.1√π*(0.5 x 10^(-3))]

σ = 1147 MPa

Thus, the material can withstand a stress of 1147 MPa

So, if tensile stress of 1000 MPa is applied, fracture will not occur because the material can withstand a higher stress of 1147 MPa before it fractures. So option B is correct.

8 0
2 years ago
Initialize the tuple team_names with the strings 'Rockets', 'Raptors', 'Warriors', and 'Celtics' (The top-4 2018 NBA teams at th
Drupady [299]

Answer:

#Initialise a tuple

team_names = ('Rockets','Raptors','Warriors','Celtics')

print(team_names[0])

print(team_names[1])

print(team_names[2])

print(team_names[3])

Explanation:

The Python code illustrates or printed out the tuple team names at the end of a season.

The code displayed is a function that will display these teams as an output from the program.

4 0
2 years ago
A horizontal, cylindrical, tank, with hemispherical ends, is used to store liquid chlorine at 10 bar. The vessel is 4 m internal
sp2606 [1]

Answer: 0.021818m =2.18x10^-²m

Explanation: Using Laplace principle

Design pressure is =12 bar= 1200000N/m²

T = Wall thickness

Design stress=110Mn/m²= 110,000,000N/m²

Radius= diameter/2 =4/2=2m

Design stress=Hoop stress =Pr/t where p=internal pressure or internal pressure, r=radius and t= wall thickness.

As Laplace equation stated.

110,000,000= 1,2000,00 x 2/t

t= 2,400,000/110,000,000.

t= 0.021818m

t=2.18x10^-2m.

3 0
2 years ago
Other questions:
  • 5. A typical paper clip weighs 0.59 g and consists of BCC iron. Calculate (a) the number of
    5·1 answer
  • On the reality television show "Survivor," two tribes compete for luxuries such as food and shelter. During such challenges, one
    12·1 answer
  • Air at 40°C flows over a long, 25-mm-diameter cylinder with an embedded electrical heater. In a series of tests, measurements we
    11·1 answer
  • Carbon dioxide gas enters a pipe at 3 MPa and 500 K at a rate of 2 kg/s. CO2 is cooled at constant pressure as it flows in the p
    10·1 answer
  • Air whose density is 0.082 lbm/ft3 enters the duct of an air-conditioning system at a volume flow rate of 450 ft3/min. If the di
    8·2 answers
  • Refrigerant-134a enters the coils of the evaporator of a refrigeration system as a saturated liquid–vapor mixture at a pressure
    5·1 answer
  • 7. Implement a function factorial in RISC-V that has a single integer parameter n and returns n!. A stub of this function can be
    9·1 answer
  • The fatigue data for a brass alloy are given as follows: Stress Amplitude (MPa) Cycles to Failure 170 3.7 × 104 148 1.0 × 105 13
    9·1 answer
  • What action below would tell your computer to "Send" an email?
    14·2 answers
  • What is the component called that usually has a dual-voltage selector switch and has cables that connect to the motherboard and
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!