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
Here are the rules for the game:
1. There are always an even number of items on the list
2. There are two colors for the players: Green and Red
3. Green starts the game
4. At each round, green plays and then red plays
5. The player takes the first and the last numbers
6. The game can end Tie when the scores are the same.
7. 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
81 4 9 7 3 6 8 8Sample Output 0
Tie 1Explanation 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