Question: 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.
 NOTE: Solve Using Python YOU CANNOT USE ANY BUILT-IN FUNCTION EXCEPT

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!