Problem Statement - Battle of the dead Daenerys Targaryen is the mother of dragons, flying on her dragons towards the north to destroy the army of dead(zombies). The zombies are oddly distributed in battlefield. She can throw dragon fire to burn zombies in a circular spot of about 5 units in diameter but she can only do this once before the dragon gets exhausted. She needs your help to decide where to throw fire in order to burn maximum possible zombies. Input You will be given a collection of coordinates in battlefield where zombies are located. Eg: [ { x: 10.5, y: 10.5 }, { x: 40.2, y: 30.6 },... ] Output Output the maximum number of zombies that can be burnt in one attack. Method Signature function burnThemAll( zombies ) => number Limits Time limit (s): 840.000 Memory limit (MB): 64 Constraints ● The size of battle field is constant (i.e. 50x50 units) for all the inputs. ● Both x and y values of the coordinates are in-between 0.0 unit and 50.0 unit. ● No two zombies are closer than 0.1 unit. ● Dragons may throw fire at any edge points of the battlefield also. ● If there is no zombie on battlefield, then return 0. ● Each zombie is considered a point. Each zombie is at a different position
function burnThemAll ( zombies ) { var feild_area = 50*50 var burt_area = 0 let z = zombies.sort(function(a, b){return b['x'] - a['y']}) // console.log(z[0].x-z[8].x) for (let i=0;i<z.length;i++){ for (let j=0;j<i+1;j++){ console.log(z[i]['x']-z[j]['x']); } // console.log(z[i]['x']-z[j]['x']) // console.log(z[i]['x']); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)