I made some code for the “Studying Alphabet” practice problem > ALPHABET Problem - CodeChef
My code outputs exactly what it should and it effectively solves the problem, however when I submit it to the site, it says It’s wrong.
Here is my code:
const readline = require(‘readline’);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
let characters = “”;
let numberOfWords = 0;
const lines = [];
rl.on(‘line’, function (line) {
if (characters === “”){
characters = line;
}
else if (numberOfWords === 0) {
numberOfWords = parseInt(line);
}
else {
lines.push(line);
if (lines.length === numberOfWords) {
rl.close();
doWork(lines, characters);
}
}
});
function doWork(lines, characters) {
for (let i = 0; i < lines.length; i++) {
handleString(lines[i], characters);
}
}
function handleString(line1, characters) {
const s1 = line1;
const c1 = characters;
let yn = "";
for (a = 0; a < s1.length; a++){
if(c1.includes(s1[a])){
yn = "yes";
}
else if (a === s1.length){
yn = "yes";
break;
}
else {
yn = "no";
break;
}
}
console.log(yn);
}