Question: Please check if your code produces same output as the one in the picture before submitting the code. It is my 3 rd time asking:

Please check if your code produces same output as the one in the picture before submitting the code. It is my 3rd time asking:(
THank you (Python)
You are a soldier in the battlefield game. The battlefield is a rectangular grid (matrix)M and the
elements in the grid are integers. If the element mij in row i and column j is positive (indices i,j start
from 0), it means there are mij enemies in this place; if mij=0, it means there is no one in this place;
if mij=-1, it means there are friend troops in this place.
You have a special weapon with power p. You can use it for one time at a selected place in a selected
direction. The following figures show the damage range for p=3 in four directions ,
larruarr ), respectively. For other value of power p, the damage range changes accordingly.
You have to find out the place and the direction to use the weapon, such that you can kill the most
enemies while no friend troops get hurt. Every enemy you killed, you get 1 reward. If no enemy is
killed, your reward is 0.
Write a program to read h+1 lines. In the first line, the height h and the width w of the grid, and
power p of the weapon are inputted. Then, h lines with w number of integers in each line,
representing the battlefield, are inputted.
If in all places and directions, some friend troops will get hurt, then the program outputs
"Friend troops will get hurt! Do not use weapon at any place!"
Otherwise, the program outputs 3 lines in the following form, even if your reward is 0 :
"You can use weapon at row x, column Y."
"The direction is D."
"Your reward is R!"
where x and Y are the row number and column number of the place, respectively, D is one of the
four directions ( uarr,darr,larrdarr,larruarr ) and R is the amount of rewards. If more than one place or
direction gives the same maximal reward, the program may output any one of them.
 Please check if your code produces same output as the one

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!