// Imagine you are working on a city planning project, and you need to optimise the placement of street lamps to illuminate as many street segments as possible. Each point in the array represents the location of a building or a potential street lamp on the X-Y plane. To minimise costs and energy consumption, you want to find the maximum number of street lamps that can be aligned in a straight line to cover multiple buildings or street segments.
// [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
// 4
let num = 6;
let slop = [];
let summm = 0;
let arr = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
for(let x = 0; x < arr.length; x++){
for(let y = x+1; y < num; y++){
if((arr[x][0]-arr[y][0])/(arr[x][1]-arr[y][1]) == -Infinity){
console.log('asdf')
slop.push(0);
continue
}
if((arr[x][0]-arr[y][0])/(arr[x][1]-arr[y][1]) == Infinity){
slop.push[0];
continue
}
console.log(((arr[x][0]-arr[y][0])/(arr[x][1]-arr[y][1])))
if(((arr[x][0]-arr[y][0])/(arr[x][1]-arr[y][1])) == -1){
summm++;
}
let a = ((arr[x][0]-arr[y][0])/(arr[x][1]-arr[y][1]))
slop.push["bsdf"];
if(true){
slop.push('a')
}
}
}
console.log(slop);
- here i was pushing with this “[” not “(”;