Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NOTE: Solve Using Python YOU CANNOT USE ANY BUILT - IN FUNCTION EXCEPT len IN PYTHON. [ negative indexing, append is prohibited ] You can

NOTE: Solve Using Python
YOU CANNOT USE ANY BUILT-IN FUNCTION EXCEPT len IN
PYTHON. [negative indexing, append is prohibited]
You can use the attribute shape of numpy arrays
YOU HAVE TO MENTION SIZE OF ARRAY WHILE INITIALIZATION
YOUR CODE SHOULD WORK FOR ANY VALID INPUTS. [Make
changes to the Sample Inputs and check whether your program works
correctly] here is the code : def play_game(arena):
#TO DO
arena=np.array([[0,2,2,0],
[50,1,2,0],
[2,2,2,0],
[1,100,2,0]
])
print_matrix(arena)
play_game(arena)
#This should print
#Points Gained: 6. Your team is out.
print(".....................")
arena=np.array([[0,2,2,0,2],
[1,50,2,1,100],
[2,2,2,0,2],
[0,200,2,0,0]
])
print_matrix(arena)
play_game(arena)
#This should print
#Points Gained: 14. Your team has survived the game. Do in this provide code.. Here is The Question: Game Arena:
Suppose you and your friends are in the world of 'Alice in Borderland' where
you decided to take part in a game and entered the game arena. As a team,
you need to gain at least 10 points in order to keep surviving in the
borderland. Otherwise, you will be out of the game and your team will be
banished for good. Now, the arena has a 2D array like structure where players
of a team are given certain positions with values that are multiples of 50. By
staying in these positions, every player can gain points from the cells above,
below, left and right (not diagonally) only if those cells contain 2[The cells
containing 1s and 0s are to be avoided]. For each player, add from these cells
containing 2s to your total points for the team to keep on surviving in
borderland. Be careful about corner cases. Your task is to write a method
which tells us whether your team is out or has survived the game.
|0|200|2|0|0|
Explanation:
Player with value 50 has 2 in the cell above, cell below and the right cell (3 cells).
Player with value 100 has 2 in the cell above and the cell below (2 cells). Player with
value 200 has 2 in the above cell and right cell (2 cells). So in total, they gained
(3+2+2)**2=14 points and survived the game.
Note: For the cell with value 2 that is common between 2 players in position (2,1), both
gained 2 points each, so it's not like if one player already added those 2 points, another
player cannot.
image text in transcribed

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago