Skip to main content
removed 43 bytes by implementing Aaron Miller's solution
Source Link
Saphereye
  • 517
  • 3
  • 8

Python3, 241198 bytes

Golfed:

def dTNV(s):
 s=s.lower()
 l=[]
 r=[]
 d=f=len(s)-2
 for i in range(len(s)):
  d=0 if s[i] in 'aeiouAEIOU' else d+1
  f=0 if s[-(i+1)] in 'aeiouAEIOU' else f+1
  l.append(d)
  r.append(f)
 return [min(l[i],r[-(i+1)]) for i in range(len(s))]
def f(s):
 v='aeiouAEIOU';l=[];r=[];L=R=len(s:=s.lower())-2
 for i in range(R+2):l.append(L:=0if s[i]in v else L+1);r.append(R:=0if s[~i]in v else R+1)
 return[min(l[x],r[~x])for x in range(len(s))]

removed 42 bytes by removing whitespace (thank you Aaron Miller)
shortenedremoved 77 bytes shortened variable names(thank you Browncat Programs)
removed 43 bytes by implementing Aaron Miller's solution(thank you Aaron Miller) 

Non-golfed:

def dTNV(s):
 s=s.lower()
 left_min=[]
 right_min=[]
 distl=distr=len(s)-2
 for i in range(len(s)):
  distl=0 if s[i] in 'aeiouAEIOU' else distl+1
  distr=0 if s[-(i+1)] in 'aeiouAEIOU' else distr+1
  left_min.append(distl)
  right_min.append(distr)
 return [min(left_min[i],right_min[-(i+1)]) for i in range(len(s))]
def dTNV(s):
 s=s.lower()
 left_min=[]
 right_min=[]
 distl=distr=len(s)-2
 for i in range(len(s)):
  distl=0 if s[i] in 'aeiouAEIOU' else distl+1
  distr=0 if s[-(i+1)] in 'aeiouAEIOU' else distr+1
  left_min.append(distl)
  right_min.append(distr)
 return [min(left_min[i],right_min[-(i+1)]) for i in range(len(s))]

Python3, 241 bytes

Golfed:

def dTNV(s):
 s=s.lower()
 l=[]
 r=[]
 d=f=len(s)-2
 for i in range(len(s)):
  d=0 if s[i] in 'aeiouAEIOU' else d+1
  f=0 if s[-(i+1)] in 'aeiouAEIOU' else f+1
  l.append(d)
  r.append(f)
 return [min(l[i],r[-(i+1)]) for i in range(len(s))]

removed 42 bytes by removing whitespace (thank you Aaron Miller)
shortened variable names(thank you Browncat Programs)

Non-golfed:

def dTNV(s):
 s=s.lower()
 left_min=[]
 right_min=[]
 distl=distr=len(s)-2
 for i in range(len(s)):
  distl=0 if s[i] in 'aeiouAEIOU' else distl+1
  distr=0 if s[-(i+1)] in 'aeiouAEIOU' else distr+1
  left_min.append(distl)
  right_min.append(distr)
 return [min(left_min[i],right_min[-(i+1)]) for i in range(len(s))]

Python3, 198 bytes

Golfed:

def f(s):
 v='aeiouAEIOU';l=[];r=[];L=R=len(s:=s.lower())-2
 for i in range(R+2):l.append(L:=0if s[i]in v else L+1);r.append(R:=0if s[~i]in v else R+1)
 return[min(l[x],r[~x])for x in range(len(s))]

removed 42 bytes by removing whitespace (thank you Aaron Miller)
removed 77 bytes shortened variable names(thank you Browncat Programs)
removed 43 bytes by implementing Aaron Miller's solution(thank you Aaron Miller) 

Non-golfed:

def dTNV(s):
 s=s.lower()
 left_min=[]
 right_min=[]
 distl=distr=len(s)-2
 for i in range(len(s)):
  distl=0 if s[i] in 'aeiouAEIOU' else distl+1
  distr=0 if s[-(i+1)] in 'aeiouAEIOU' else distr+1
  left_min.append(distl)
  right_min.append(distr)
 return [min(left_min[i],right_min[-(i+1)]) for i in range(len(s))]
added 348 characters in body
Source Link
Saphereye
  • 517
  • 3
  • 8

Python3, 318241 bytes

Golfed:

def dTNV(s):
 s=s.lower()
 left_min=[]l=[]
 right_min=[]r=[]
 distl=distr=lend=f=len(s)-2
 for i in range(len(s)):
  distl=0d=0 if s[i] in 'aeiouAEIOU' else distl+1d+1
  distr=0f=0 if s[-(i+1)] in 'aeiouAEIOU' else distr+1f+1
  left_minl.append(distld)
  right_minr.append(distrf)
 return [min(left_min[i]l[i],right_min[r[-(i+1)]) for i in range(len(s))]

removed 42 bytes by removing whitespace (thank you Aaron Miller)
shortened variable names(thank you Browncat Programs)

Non-golfed:

def dTNV(s):
 s=s.lower()
 left_min=[]
 right_min=[]
 distl=distr=len(s)-2
 for i in range(len(s)):
  distl=0 if s[i] in 'aeiouAEIOU' else distl+1
  distr=0 if s[-(i+1)] in 'aeiouAEIOU' else distr+1
  left_min.append(distl)
  right_min.append(distr)
 return [min(left_min[i],right_min[-(i+1)]) for i in range(len(s))]

Python3, 318 bytes

def dTNV(s):
 s=s.lower()
 left_min=[]
 right_min=[]
 distl=distr=len(s)-2
 for i in range(len(s)):
  distl=0 if s[i] in 'aeiouAEIOU' else distl+1
  distr=0 if s[-(i+1)] in 'aeiouAEIOU' else distr+1
  left_min.append(distl)
  right_min.append(distr)
 return [min(left_min[i],right_min[-(i+1)]) for i in range(len(s))]

removed 42 bytes by removing whitespace (thank you Aaron Miller)

Python3, 241 bytes

Golfed:

def dTNV(s):
 s=s.lower()
 l=[]
 r=[]
 d=f=len(s)-2
 for i in range(len(s)):
  d=0 if s[i] in 'aeiouAEIOU' else d+1
  f=0 if s[-(i+1)] in 'aeiouAEIOU' else f+1
  l.append(d)
  r.append(f)
 return [min(l[i],r[-(i+1)]) for i in range(len(s))]

removed 42 bytes by removing whitespace (thank you Aaron Miller)
shortened variable names(thank you Browncat Programs)

Non-golfed:

def dTNV(s):
 s=s.lower()
 left_min=[]
 right_min=[]
 distl=distr=len(s)-2
 for i in range(len(s)):
  distl=0 if s[i] in 'aeiouAEIOU' else distl+1
  distr=0 if s[-(i+1)] in 'aeiouAEIOU' else distr+1
  left_min.append(distl)
  right_min.append(distr)
 return [min(left_min[i],right_min[-(i+1)]) for i in range(len(s))]
added 34 characters in body
Source Link
Saphereye
  • 517
  • 3
  • 8

Python3Python3, 360318 bytes

def dTNV(s):
    s=s.lower()
    left_min=[]
    right_min=[]
    distl=distr=len(s)-2
    for i in range(len(s)):
        distl=0 if s[i] in 'aeiouAEIOU' else distl+1
        distr=0 if s[-(i+1)] in 'aeiouAEIOU' else distr+1
        left_min.append(distl)
        right_min.append(distr)
    return [min(left_min[i],right_min[-(i+1)]) for i in range(len(s))]

removed 42 bytes by removing whitespace (thank you Aaron Miller)

Python3, 360 bytes

def dTNV(s):
    s=s.lower()
    left_min=[]
    right_min=[]
    distl=distr=len(s)-2
    for i in range(len(s)):
        distl=0 if s[i] in 'aeiouAEIOU' else distl+1
        distr=0 if s[-(i+1)] in 'aeiouAEIOU' else distr+1
        left_min.append(distl)
        right_min.append(distr)
    return [min(left_min[i],right_min[-(i+1)]) for i in range(len(s))]

Python3, 318 bytes

def dTNV(s):
 s=s.lower()
 left_min=[]
 right_min=[]
 distl=distr=len(s)-2
 for i in range(len(s)):
  distl=0 if s[i] in 'aeiouAEIOU' else distl+1
  distr=0 if s[-(i+1)] in 'aeiouAEIOU' else distr+1
  left_min.append(distl)
  right_min.append(distr)
 return [min(left_min[i],right_min[-(i+1)]) for i in range(len(s))]

removed 42 bytes by removing whitespace (thank you Aaron Miller)
Source Link
Saphereye
  • 517
  • 3
  • 8
Loading