162k views
3 votes
A video game developer is developing a game in which the character makes their way through several segments of a level. in each segment, if the character collects a coin, the player scores a point. however, if a segment does not contain a coin, the player loses a point. player 1 always begins the level, and, at some point, game play is turned over to player 2 to complete the level. player 1's goal is to achieve a higher score than player 2 once the level is completed. given the status of game segments (whether they contain a coin or not), determine the minimum number of segments player 1 should play so that, in the end, their score is greater than player 2's score.

Example
segments =[1,1,0,1]
Player 1 has the following options:
Play 0segments. This would give them a score of 0 Player 2 would have a score of 3-1=2(because they gain a point for each of the 3segments with a coin, and lose 1point for the segment without a coin)
.Play 1segment. This would give them a score of 1Player 2would have a score of 2*1=1
Play 2segments. This would give them a score of 2Player 2would have a score of l *l=0

User Bork Blatt
by
8.6k points

2 Answers

6 votes

Final answer:

To achieve a higher score than player 2, player 1 should play at least 1 segment with a coin.

Step-by-step explanation:

To determine the minimum number of segments player 1 should play in order to achieve a higher score than player 2, we need to analyze the game scenario. Player 1's goal is to have a higher score than player 2, so it's important for player 1 to maximize their own score while minimizing player 2's score. Let's consider the possible scenarios:

  1. If player 1 plays 0 segments, their score will be 0 and player 2's score will be the number of segments with a coin minus the number of segments without a coin. So, player 2's score will be higher than player 1's score.
  2. If player 1 plays 1 segment, their score will be 1 and player 2's score will be the number of segments with a coin multiplied by 1. In this case, player 1's score can be greater than player 2's score if the number of segments with a coin is greater than 1.
  3. If player 1 plays 2 segments, their score will be 2 and player 2's score will be the number of segments with a coin multiplied by 0. In this case, player 1's score can be greater than player 2's score if the number of segments with a coin is greater than or equal to 1.

Based on these scenarios, we can determine that the minimum number of segments player 1 should play is 1, if there is at least 1 segment with a coin. This ensures that player 1 will have a higher score than player 2 in the end.

User Kabr
by
9.1k points
2 votes

Final answer:

To determine the minimum number of segments player 1 should play so that their score is greater than player 2's score, we need to consider the different scenarios and their outcomes.

Step-by-step explanation:

To determine the minimum number of segments player 1 should play so that their score is greater than player 2's score, we need to consider the different scenarios and their outcomes. Let's look at an example with segments [1, 1, 0, 1].

If player 1 plays 0 segments, their score would be 0. Player 2 would have a score of 3-1=2, as they gain a point for each segment with a coin and lose a point for the segment without a coin.

If player 1 plays 1 segment, their score would be 1. Player 2 would have a score of 2*1=2.

If player 1 plays 2 segments, their score would be 2. Player 2 would have a score of 1*1=1.

Based on these scenarios, player 1 needs to play 2 segments to have a higher score than player 2. This ensures that their score is greater than player 2's score once the level is completed.

User Andrew MacNaughton
by
7.8k points