Skip to content

Instantly share code, notes, and snippets.

@Pragalbha-Patil
Created May 31, 2020 16:13
Show Gist options
  • Save Pragalbha-Patil/731a5d31c37030fd31c74c9a61684631 to your computer and use it in GitHub Desktop.
Save Pragalbha-Patil/731a5d31c37030fd31c74c9a61684631 to your computer and use it in GitHub Desktop.
'use strict';
const fs = require('fs');
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', function(inputStdin) {
inputString += inputStdin;
});
process.stdin.on('end', function() {
inputString = inputString.split('\n');
main();
});
function readLine() {
return inputString[currentLine++];
}
/*
* Complete the 'isPangram' function below.
*
* The function is expected to return a STRING.
* The function accepts STRING_ARRAY pangram as parameter.
*/
function isPangram(pangram) {
let alphabet = '';
let assemble = '';
let remove;
let stringToCheck;
let final;
for(var k = 0; k < pangram.length; k++) {
alphabet = "abcdefghijklmnopqrstuvwxyz";
stringToCheck = pangram[k];
for (var i = 0; i < stringToCheck.length; i++) {
remove = alphabet.indexOf(stringToCheck[i]);
if(stringToCheck[i] == alphabet[remove]) {
alphabet = alphabet.replace(stringToCheck[i], '');
}
}
console.log("Alphabet looks like: "+alphabet);
if(alphabet.length == 0) {
assemble = assemble.concat('1');
}
else {
assemble = assemble.concat('0');
}
final = assemble;
}
return final;
}
function main() {
const ws = fs.createWriteStream(process.env.OUTPUT_PATH);
const pangramCount = parseInt(readLine().trim(), 10);
let pangram = [];
for (let i = 0; i < pangramCount; i++) {
const pangramItem = readLine();
pangram.push(pangramItem);
}
const result = isPangram(pangram);
ws.write(result + '\n');
ws.end();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment