My issue
for _ in range(int(input())):
n= int(input())
s= str(input())
count=1
alphabet=‘abcdefghijklmnopqrstuvwxyz’
vowels=‘aeiou’
a=alphabet.find(‘a’)
e=alphabet.find(‘e’)
i=alphabet.find(‘i’)
o=alphabet.find(‘o’)
u=alphabet.find(‘u’)
for item in s:
if item not in vowels:
distance=[abs(alphabet.find('item')-a),abs(alphabet.find('item')-e),abs(alphabet.find('item')-i),abs(alphabet.find('item')-o),abs(alphabet.find('item')-u)]
if (distance.count(min(distance)))>1 :
count+=1
print(count)
‘’‘where is this code going wrong??’‘’
My code
# cook your dish here
for _ in range(int(input())):
n= int(input())
s= str(input())
count=1
alphabet='abcdefghijklmnopqrstuvwxyz'
vowels='aeiou'
a=alphabet.find('a')
e=alphabet.find('e')
i=alphabet.find('i')
o=alphabet.find('o')
u=alphabet.find('u')
for item in s:
if item not in vowels:
distance=[abs(alphabet.find('item')-a),abs(alphabet.find('item')-e),abs(alphabet.find('item')-i),abs(alphabet.find('item')-o),abs(alphabet.find('item')-u)]
if (distance.count(min(distance)))>1 :
count+=1
print(count)
Problem Link: CLOSEVOWEL Problem - CodeChef