Skip to content

Instantly share code, notes, and snippets.

@Cool-sami12
Forked from stephengfriend/index.js
Created May 17, 2020 17:48
Show Gist options
  • Select an option

  • Save Cool-sami12/d2957e40286928f54e0cbd1970131ee5 to your computer and use it in GitHub Desktop.

Select an option

Save Cool-sami12/d2957e40286928f54e0cbd1970131ee5 to your computer and use it in GitHub Desktop.
Monk Takes a Walk
// Sample code to perform I/O:
process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";
process.stdin.on("data", function (input) {
stdin_input += input; // Reading input from STDIN
});
process.stdin.on("end", function () {
main(stdin_input);
});
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
// Write your code here
function main(input) {
const lines = input.split('\n'); // ['nBBZLaosnm', 'JHkIsnZtTL']
const numOfTests = lines.shift(); // 2
const vowels = ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'];
lines.forEach((trees) => {
const treesWithVowels = trees.split('').filter((tree) => {
return vowels.includes(tree);
}); // [ 'a', 'o']
console.log(treesWithVowels.length);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment