Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 rd time asking:
THank you Python
You are a soldier in the battlefield game. The battlefield is a rectangular grid matrix and the
elements in the grid are integers. If the element in row i and column is positive indices start
from it means there are enemies in this place; if it means there is no one in this place;
if it means there are friend troops in this place.
You have a special weapon with power You can use it for one time at a selected place in a selected
direction. The following figures show the damage range for in four directions
larruarr respectively. For other value of power 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 reward. If no enemy is
killed, your reward is
Write a program to read lines. In the first line, the height and the width of the grid, and
power of the weapon are inputted. Then, lines with 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 lines in the following form, even if your reward is :
"You can use weapon at row column Y
"The direction is D
"Your reward is R
where and are the row number and column number of the place, respectively, is one of the
four directions uarrdarrlarrdarr,larruarr and 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started