Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
Find unique node number given x and y coordinates

here

Referring to this picture, the first array is x-coordinate and second array is y-coordinate. The blue boxes will be the node number for each (x,y). if the point has been labelled before, it will remain with the same node number that was assigned to it previously. And if the point has not been labelled before and is new, it will be assigned a new node number :) For my attempt, I am trying to find the index of all mirror coordinates and the number of mirror coordinates present with the code below. However, I am unsure what the next step should be to get the value of the blue boxes in an array. This is in javascript. Any guidance will be appreaciated :)

for (let i=0;i<jaja+1;i++){
      if ( (x_all[arr[m]+i]==x_all[arr[m]-i])  ){
    }
    }
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This is a fairly straightforward 'zip' with an added map of previously seen points, here tracked in an object keyed by the JSON string of each point, and retrieving/setting the next id using logical nullish assignment (??=).

const xs = [102, 152, 202, 252, 202, 152, 302, 10, 332, 10, 1];
const ys = [100, 50, 60, 70, 60, 9, 3, 2, 1, 2, 100];

let seen = {}, count = 1;
const result = xs.map((x, i) => {
  const point = { x, y: ys[i] };
  const id = (seen[JSON.stringify(point)] ??= count++);
  return { id, ...point };
})

console.log(result)

see more 'zip' discussion here: Javascript equivalent of Python's zip function

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!