India’s Best Job Seekers and Training Platform Forums Java Problems set Consider a battlefield to be made up of square cells of…

  • Consider a battlefield to be made up of square cells of…

  • Akash 

    Administrator
    at

    Consider a battlefield to be made up of square cells of unit dimensions. a soldier on the battlefield can move from a cell to all(8) of it’s neighboring cells. soldier has a gun with with him which he can shoot the targets up to any distance along any of the 8 possible directions (north,east,west,south,north-east,north- west,south- east,south- west). also some sell are bulletproof which prevents bullets to pass but soldier can walk over them as if it were a normal cell.he can destroy the target from a bulletproof cell but not from a cell behind it.

    position of a target/ soldier can be given by the cell, they are on.given the position of the target, starting position of a target and position of all the bullet proof cells. you have to tell the position of closest shooting point i.e the cell from which, the soldier can shoot the target and is closest to the starting position of the soldier. if there are more than such cells, output all of them.

    Input/output specifications :

    Input specifications :

    I) size of the battlefield { integer pair (N,M) : battlefield will be of N*M size )

    II) staring position of the soldier {integer pair (i,j)}

    III) position of the target {integer pair (x,y) : position of the cell on which target is mounted}

    IV) position of the all bullet proof cells { list of integer pair a#b : each element in the list is a position of bullet proof cells }

    output specifications :

    sequential list of integer pair i#j (cell) that are closest shoot points and must fallow row wise traversal.

    Note: if the output list contains four shoot points : (2,1), (1,2), (3,2), (2,4) on a 4×4 battle field.

    then the correct output will be {1#2,2#1,2#4,3#2} not {1#2,2#1,3#2,2#4}

    Examples:

    Input : {2,2} {2,1} {2,2} {1#1,1#2}

    output : 2#1

    below is the method signature in java:

    public static String[] nearest_shoot_point(int[] input1,int[] input2,int[] input3String[] input4){

    }                            

Log in to reply.

Original Post
0 of 0 posts June 2018
Now
KodNest Training New Batch is starting on 02nd November 2020. Attend one week free demo classes.Register Now

New Report

Close