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

339
Views
Problemas con ProcessData Node.js stin/stdout)

Tengo algunos problemas para entender cómo ejecutar mi código usando una función de ajuste de ProcessData en hackerrank (node.js). Parece que no puedo descartar una función con los parámetros que tengo en el envoltorio ProcessData sin volver ~sin respuesta en la salida estándar~. ¿Cómo paso su entrada (una cadena de números enteros) a mi función y obtengo una respuesta de algún tipo para poder depurar? La ayuda definitivamente sería apreciada. Consulte mi función, el entorno de codificación, la entrada y la salida esperada a continuación. ¡Gracias!

Para referencia: https://www.hackerrank.com/challenges/array-left-rotation

 /* Input Format The first line contains two space-separated integers denoting the respective values of (the number of integers) and (the number of left rotations you must perform). The second line contains space-separated integers describing the respective elements of the array's initial state. */ /*Environment with my code, below (how do I pass input as an argument to this function?? console.log or return the data, and get a response for debugging?)*/ function processData(input) { //Enter your code here var rotate = function(num,turns,ar){ var store = ar.slice(0, turns); for(var i=0; i<store.length; i++){ ar.shift(); ar.push(store[i]); } return ar; }; } process.stdin.resume(); process.stdin.setEncoding("ascii"); _input = ""; process.stdin.on("data", function (input) { _input += input; }); process.stdin.on("end", function () { processData(_input); });
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Necesita usar process.stdout.write . Por ejemplo:

 function processData(input) { //Enter your code here process.stdout.write('5 1 2 3 4'); }
over 4 years ago · Santiago Trujillo Report

0

en su lugar usa
dejar entrada = 4; //4 es una variable entera

función procesarDatos(entrada) {

//antes de generar el integro, debe convertirlo en una cadena usando toString();

 process.stdout.write(input.toString().trim());

}


//Tenga en cuenta que la salida se convierte en cadena
Salida: 4

over 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!