Submission details
Task:Palindromi
Sender:j-l
Submission time:2025-11-01 16:28:16 +0200
Language:Node.js
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.12 sdetails
#20.12 sdetails
#30.12 sdetails
#40.12 sdetails
#50.12 sdetails
#60.12 sdetails
#70.12 sdetails
#80.12 sdetails
#90.12 sdetails
#100.12 sdetails

Code

const readline = require('readline');

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

async function setCharAt(str, index, char) {
    if (index < 0 || index >= str.length) {
      return str;
    }
    return (str.slice0, index) + char + str.slice(index + 1);
}

async function palindromiEquals(wordOrigin){
    let txtlength = 0;
    let result1 = "";
    let result2 = "";
    while ((wordOrigin.length/2) > txtlength) {
        result1 = result1+wordOrigin.charAt(txtlength);
        result2 = wordOrigin.charAt(txtlength+(Math.floor(wordOrigin.length/2)))+result2;
        txtlength += 1;
    };
    return result1, result2;
};

async function palindromi(wordOrigin){
    let txtlength = 0;
    let result1 = "";
    let result2 = "";
    result1, result2 = palindromiEquals(wordOrigin);
    if (result1 == result2) {
        return 0;
    }else{
        result1 = "";
        result2 = "";
        txtlength = 0;
        let final = 0;
        let char = "";
        while(true){
            if (wordOrigin.charAt((wordOrigin.lenght)-(txtlength+1)) != wordOrigin.charAt(txtlength)) {
                char = wordOrigin.charAt(txtlength);
                wordOrigin = setCharAt(wordOrigin, (wordOrigin.lenght)-(txtlength+1), String(char));
                final += 1;
            };
            txtlength += 1;
            if (wordOrigin.length < txtlength) {
                break;
            };
        };
        return final;
    };
};

rl.question("", (text) => {
    console.log(palindromi(text));
    rl.close();
});

Test details

Test 1 (public)

Verdict:

input
datatahti

correct output
3

user output
Promise {
  <rejected> TypeError: wordOr...

Error:
(node:3) UnhandledPromiseRejectionWarning: TypeError: wordOrigin.charAt is not a function
    at palindromi (/box/input/code.js:41:28)
    at /box/input/code.js:56:17
    at Interface._onLine (readline.js:327:5)
    at Interface._normalWrite (readline.js:474:12)
    at ReadStream.ondata (readline.js:186:10)
    at ReadStream.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at ReadStream.Readable.push (_stream_readable.js:213:10)
    at internal/fs/streams.js:215:14
(node:3) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3) [DEP0018] Deprecatio...

Test 2 (public)

Verdict:

input
saippuakauppias

correct output
0

user output
Promise {
  <rejected> TypeError: wordOr...

Error:
(node:3) UnhandledPromiseRejectionWarning: TypeError: wordOrigin.charAt is not a function
    at palindromi (/box/input/code.js:41:28)
    at /box/input/code.js:56:17
    at Interface._onLine (readline.js:327:5)
    at Interface._normalWrite (readline.js:474:12)
    at ReadStream.ondata (readline.js:186:10)
    at ReadStream.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at ReadStream.Readable.push (_stream_readable.js:213:10)
    at internal/fs/streams.js:215:14
(node:3) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3) [DEP0018] Deprecatio...

Test 3 (public)

Verdict:

input
a

correct output
0

user output
Promise {
  <rejected> TypeError: wordOr...

Error:
(node:3) UnhandledPromiseRejectionWarning: TypeError: wordOrigin.charAt is not a function
    at palindromi (/box/input/code.js:41:28)
    at /box/input/code.js:56:17
    at Interface._onLine (readline.js:327:5)
    at Interface._normalWrite (readline.js:474:12)
    at ReadStream.ondata (readline.js:186:10)
    at ReadStream.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at ReadStream.Readable.push (_stream_readable.js:213:10)
    at internal/fs/streams.js:215:14
(node:3) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3) [DEP0018] Deprecatio...

Test 4 (public)

Verdict:

input
aa

correct output
0

user output
Promise {
  <rejected> TypeError: wordOr...

Error:
(node:3) UnhandledPromiseRejectionWarning: TypeError: wordOrigin.charAt is not a function
    at palindromi (/box/input/code.js:41:28)
    at /box/input/code.js:56:17
    at Interface._onLine (readline.js:327:5)
    at Interface._normalWrite (readline.js:474:12)
    at ReadStream.ondata (readline.js:186:10)
    at ReadStream.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at ReadStream.Readable.push (_stream_readable.js:213:10)
    at internal/fs/streams.js:215:14
(node:3) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3) [DEP0018] Deprecatio...

Test 5 (public)

Verdict:

input
abc

correct output
1

user output
Promise {
  <rejected> TypeError: wordOr...

Error:
(node:3) UnhandledPromiseRejectionWarning: TypeError: wordOrigin.charAt is not a function
    at palindromi (/box/input/code.js:41:28)
    at /box/input/code.js:56:17
    at Interface._onLine (readline.js:327:5)
    at Interface._normalWrite (readline.js:474:12)
    at ReadStream.ondata (readline.js:186:10)
    at ReadStream.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at ReadStream.Readable.push (_stream_readable.js:213:10)
    at internal/fs/streams.js:215:14
(node:3) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3) [DEP0018] Deprecatio...

Test 6 (public)

Verdict:

input
aybabtu

correct output
2

user output
Promise {
  <rejected> TypeError: wordOr...

Error:
(node:3) UnhandledPromiseRejectionWarning: TypeError: wordOrigin.charAt is not a function
    at palindromi (/box/input/code.js:41:28)
    at /box/input/code.js:56:17
    at Interface._onLine (readline.js:327:5)
    at Interface._normalWrite (readline.js:474:12)
    at ReadStream.ondata (readline.js:186:10)
    at ReadStream.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at ReadStream.Readable.push (_stream_readable.js:213:10)
    at internal/fs/streams.js:215:14
(node:3) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3) [DEP0018] Deprecatio...

Test 7 (public)

Verdict:

input
abacabaca

correct output
2

user output
Promise {
  <rejected> TypeError: wordOr...

Error:
(node:3) UnhandledPromiseRejectionWarning: TypeError: wordOrigin.charAt is not a function
    at palindromi (/box/input/code.js:41:28)
    at /box/input/code.js:56:17
    at Interface._onLine (readline.js:327:5)
    at Interface._normalWrite (readline.js:474:12)
    at ReadStream.ondata (readline.js:186:10)
    at ReadStream.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at ReadStream.Readable.push (_stream_readable.js:213:10)
    at internal/fs/streams.js:215:14
(node:3) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3) [DEP0018] Deprecatio...

Test 8 (public)

Verdict:

input
bbbbaaaababbbbbaabaaabaaaaabab...

correct output
23

user output
Promise {
  <rejected> TypeError: wordOr...

Error:
(node:3) UnhandledPromiseRejectionWarning: TypeError: wordOrigin.charAt is not a function
    at palindromi (/box/input/code.js:41:28)
    at /box/input/code.js:56:17
    at Interface._onLine (readline.js:327:5)
    at Interface._normalWrite (readline.js:474:12)
    at ReadStream.ondata (readline.js:186:10)
    at ReadStream.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at ReadStream.Readable.push (_stream_readable.js:213:10)
    at internal/fs/streams.js:215:14
(node:3) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3) [DEP0018] Deprecatio...

Test 9 (public)

Verdict:

input
acbaaabaabaddaccdcccbcdbdddacd...

correct output
38

user output
Promise {
  <rejected> TypeError: wordOr...

Error:
(node:3) UnhandledPromiseRejectionWarning: TypeError: wordOrigin.charAt is not a function
    at palindromi (/box/input/code.js:41:28)
    at /box/input/code.js:56:17
    at Interface._onLine (readline.js:327:5)
    at Interface._normalWrite (readline.js:474:12)
    at ReadStream.ondata (readline.js:186:10)
    at ReadStream.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at ReadStream.Readable.push (_stream_readable.js:213:10)
    at internal/fs/streams.js:215:14
(node:3) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3) [DEP0018] Deprecatio...

Test 10 (public)

Verdict:

input
uaqtmfftecryanvpshxsodjrllqnqp...

correct output
49

user output
Promise {
  <rejected> TypeError: wordOr...

Error:
(node:3) UnhandledPromiseRejectionWarning: TypeError: wordOrigin.charAt is not a function
    at palindromi (/box/input/code.js:41:28)
    at /box/input/code.js:56:17
    at Interface._onLine (readline.js:327:5)
    at Interface._normalWrite (readline.js:474:12)
    at ReadStream.ondata (readline.js:186:10)
    at ReadStream.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at ReadStream.Readable.push (_stream_readable.js:213:10)
    at internal/fs/streams.js:215:14
(node:3) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3) [DEP0018] Deprecatio...