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

81 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

Step: 3

blur-text-image

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Name the five levels of the Capability Maturity Model.

Answered: 1 week ago