Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda