Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  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

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions

Question

Project management skills and/or experience desirable

Answered: 1 week ago