Question
AGU Computer Engineering Department created a new mathematical game that can be played with two people. In this game, you are given a list of
AGU Computer Engineering Department created a new mathematical game that can be played with two people. In this game, you are given a list of random integers. At each round, the first player takes two numbers from the list and calculates the sum of these numbers. Then, the second player takes two numbers and makes the same calculation. The higher one is going to take the round and increment the score by 1. At the end of the game, who has the better score will win the game.
Here are the rules for the game:
-
There are always an even number of items on the list
-
There are two colors for the players: Green and Red
-
Green starts the game
-
At each round, green plays and then red plays
-
The player takes the first and the last numbers
-
The game can end Tie when the scores are the same.
-
The game will end when there is no element to take from the list
Your program will simulate the rounds and find out the winner, Green or Red or Tie. The input will be two lines.
Input Format
The first line gives the number of items, n, and the next line includes n integers representing the list.
Constraints
The given n is always an even number
Output Format
The output will be a single line showing the winner color, Red or Green or Tie, and the winner's score.
Sample Input 0
8 1 4 9 7 3 6 8 8
Sample Output 0
Tie 1
Explanation 0
Round 1: Red wins (Green: 1+8, Red: 4+8) Round 2: Green wins (Green: 9+6, Red: 7+3) Red : 1 & Green: 1 -> Tie
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started