Problem Statement:

Hawkeye is a MARVEL character who has a perfect aim in archery. Its almost impossible for him to miss his aim. As you are the head of technical team at MARVEL , you have been assigned a very critical task. During practice hawkeye uses a square archery practice board. For our convenience we will assume it to be a N * N matrix. He shoots an arrow at position i,j with power P. Now power reduces by 1 as we move away from position i,j . Your task is to show the graph representing the impact of the arrow on the practice board.
INPUT FORMAT
First line of input contains a single integer N denoting the size of the practice board.
Second line contains 3 integers i,j denoting position at which arrow was shot and p denoting the power used to shoot the arrow.
First line of input contains a single integer N denoting the size of the practice board.
Second line contains 3 integers i,j denoting position at which arrow was shot and p denoting the power used to shoot the arrow.
OUTPUT FORMAT
Output a 2D matrix representing the impact on the practice board.
Output a 2D matrix representing the impact on the practice board.
CONSTRAINS
1<=N<=1000
0<=i,j 0<=p<=109
1<=N<=1000
0<=i,j 0<=p<=109
Note:- The matrix is zero indexed matrix ie: first element will be at 0,0
Programming using python 2.7.6:
Size_of_Board = int(raw_input())
Pos1,Pos2,Power = map(int,raw_input().split())
def get_max(x1,y1,x2,y2):
x = x1 - x2
y = y1 - y2
return max(abs(x),abs(y))
def get_difference_value(power,maxval):
if (power - maxval) > 0:
return (power - maxval)
else:
return 0
for a in range(Size_of_Board):
for b in
range(Size_of_Board):
print
get_difference_value(Power,get_max(Pos1,Pos2,a,b)),
print
No comments:
Post a Comment