█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 3666

Problema 0x78 - Suma de 2 números

  • Autor: jvelezpo
  • Fecha: 2021-04-08 18:40:45 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
/box/script.js:8
  return a.reduce((a, b) => Number(a) + Number(b), 0)
  ^

ReferenceError: a is not defined
    at sumElements (/box/script.js:8:3)
    at Interface.<anonymous> (/box/script.js:19:10)
    at Interface.emit (events.js:210:5)
    at Interface._onLine (readline.js:316:10)
    at Interface._normalWrite (readline.js:461:12)
    at ReadStream.ondata (readline.js:172:10)
    at ReadStream.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at ReadStream.Readable.push (_stream_readable.js:224:10)
0.032 s 7 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
/box/script.js:8
  return a.reduce((a, b) => Number(a) + Number(b), 0)
  ^

ReferenceError: a is not defined
    at sumElements (/box/script.js:8:3)
    at Interface.<anonymous> (/box/script.js:19:10)
    at Interface.emit (events.js:210:5)
    at Interface._onLine (readline.js:316:10)
    at Interface._normalWrite (readline.js:461:12)
    at ReadStream.ondata (readline.js:172:10)
    at ReadStream.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at ReadStream.Readable.push (_stream_readable.js:224:10)
0.036 s 8 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
/box/script.js:8
  return a.reduce((a, b) => Number(a) + Number(b), 0)
  ^

ReferenceError: a is not defined
    at sumElements (/box/script.js:8:3)
    at Interface.<anonymous> (/box/script.js:19:10)
    at Interface.emit (events.js:210:5)
    at Interface._onLine (readline.js:316:10)
    at Interface._normalWrite (readline.js:461:12)
    at ReadStream.ondata (readline.js:172:10)
    at ReadStream.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at ReadStream.Readable.push (_stream_readable.js:224:10)
0.052 s 7 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
/box/script.js:8
  return a.reduce((a, b) => Number(a) + Number(b), 0)
  ^

ReferenceError: a is not defined
    at sumElements (/box/script.js:8:3)
    at Interface.<anonymous> (/box/script.js:19:10)
    at Interface.emit (events.js:210:5)
    at Interface._onLine (readline.js:316:10)
    at Interface._normalWrite (readline.js:461:12)
    at ReadStream.ondata (readline.js:172:10)
    at ReadStream.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at ReadStream.Readable.push (_stream_readable.js:224:10)
0.039 s 7 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
/box/script.js:8
  return a.reduce((a, b) => Number(a) + Number(b), 0)
  ^

ReferenceError: a is not defined
    at sumElements (/box/script.js:8:3)
    at Interface.<anonymous> (/box/script.js:19:10)
    at Interface.emit (events.js:210:5)
    at Interface._onLine (readline.js:316:10)
    at Interface._normalWrite (readline.js:461:12)
    at ReadStream.ondata (readline.js:172:10)
    at ReadStream.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at ReadStream.Readable.push (_stream_readable.js:224:10)
0.099 s 32 KBi
Puntos totales: 0 / 100

Código

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
})

function sumElements(arr){
  return a.reduce((a, b) => Number(a) + Number(b), 0)
}

let lineNumber = 0;
let arr = [];
let result = 0

rl.on("line", line => {
  ++lineNumber;
  if (lineNumber === 1) {
   arr = [...line.split(' ')]
result = sumElements(arr)
console.log(result);
  }
})