Skip to content

Instantly share code, notes, and snippets.

@stephengfriend
Created May 11, 2020 13:01
Show Gist options
  • Select an option

  • Save stephengfriend/435f72673f4d07a4c6de814c738f3f84 to your computer and use it in GitHub Desktop.

Select an option

Save stephengfriend/435f72673f4d07a4c6de814c738f3f84 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