Atom feed

Recently added: 02 Count Of Subset Sum, 416 Partition Equal Subset Sum, 01 Subset Sum, 518 Coin Change 2, 983 Minimum Cost For Tickets

01 Monk Takes Walk

 * Created by Ashish Patel
 * Copyright © 2018

/* Today, Monk went for a walk in a garden. There are many trees in the garden and each tree has an English alphabet on it. While Monk was walking, he noticed that all trees with vowels on it are not in good state. He decided to take care of them. So, he asked you to tell him the count of such trees in the garden. 
Note : The following letters are vowels: 'A', 'E', 'I', 'O', 'U' ,'a','e','i','o' and 'u'.

The first line consists of an integer T denoting the number of test cases.
Each test case consists of only one string, each character of string denoting the alphabet (may be lowercase or uppercase) on a tree in the garden.

For each test case, print the count in a new line. */

const stdInput = 

function main(input) {
    const inputArray = input.split('\n');
    const numOfStrings = Number(inputArray[0]);
    for(let i=1; i<=numOfStrings; i++) { 
        const vowels = inputArray[i].match(/[aeiou]/gi) || [];
        vowels.length > 0 ? console.log(vowels.length) : console.log(0);  


Created 2019-11-30T02:01:21+05:18 · Edit