`{a, e, i, o, u, A, E, I, O, U}`

Natural Language Understanding is the subdomain of Natural Language Processing where people used to design AI based applications have ability to understand the human languages. HashInclude Speech Processing team has a project named Virtual Assistant. For this project they appointed you as a data engineer (who has good knowledge of creating clean datasets by writing efficient code). As a data engineer your first task is to make vowel recognition dataset. In this task you have to find the presence of vowels in all possible substrings of the given string. For each given string you have to return the total number of vowels.

## Example

Given a string `"baceb"` you can split it into substrings: `b, ba, bac, bace, baceb, a, ac, ace, aceb, c, ce, ceb, e, eb, b`. The number of vowels in each of these substrings is `0, 1, 1, 2, 2, 1, 1, 2, 2, 0, 1, 1, 1, 1, 0`; if you sum up these number, you get `16` - the expected output.

**Note**: your solution should have linear time complexity.

Difficulty: introductory

Starter code:

def vowel_recognition(s):
	

Solutions:
def vowel_recognition(input):
    vowels = set('aeiouAEIOU')
    s = t = 0
    for c, e in enumerate(input, 1):
        if e in vowels:
            t += c
        s += t
    return s

def vowel_recognition(input):
    chars = input.lower()
    N = len(chars)
    count = 0
    
    for i, c in enumerate(chars):
        if c in 'aeiou':
            count += (N - i) * (i + 1)
            
    return count

def vowel_recognition(s):
    a = [0] * (len(s) + 1)
    for i, c in enumerate(s.lower()):
        a[i] = (c in 'aeiou') * (i+1) + 2 * a[i-1] - a[i-2]
    return a[-2]


import re

def vowel_recognition(s):
    return sum( (len(s)-m.start())*(1+m.start()) for m in re.finditer(r'(?i)[aeiou]',s))

def vowel_recognition(s):
    return sum((i + 1) * (len(s) - i) for i, c in enumerate(s.lower()) if c in 'aeiou')

def vowel_recognition(s):
    return sum((i + 1) * (len(s) - i) for i, c in enumerate(s) if c in 'AEIOUaeiou')

vowels = "aeiou"


def vowel_recognition(stg):
    l = len(stg)
    return sum((i + 1) * (l - i) for i, c in enumerate(stg.lower()) if c in vowels)

def vowel_recognition(s):
    l = len(s)
    return sum((l-i)*(i+1) for i,j in enumerate(s) if j in 'aeiouAEIOU')

def vowel_recognition(s):
    return sum((len(s) - i) * (i + 1) for i,ch in enumerate(s) if ch in 'aeiouAEIOU')

def vowel_recognition(input): #Played around with some maths haha took way too much time
    vl = ["a","e","i","o","u","A","E","I","O","U"]
    n = len(input)
    count = 0
    for num, letter in enumerate(input):
        for vowel in vl:
            if letter == vowel:
                x = num+1
                count += x*(n-x+1)
    return count