Distance to nearest vowel
Write a function that takes a string as argument. Each character in the string will be a letter. The function should return a sequence containing the distances from each corresponding letter in the string to the nearest vowel in the string.
For example:
(nearest-vowels "aeiou") ;=> [0 0 0 0 0] ;; if the letter is a vowel, the distance is 0
(nearest-vowels "babbb") ;=> [1 0 1 2 3]
(nearest-vowels "babbba") ;=> [1 0 1 2 1 0]
Notes:
- All input strings will contain at least one vowel and all letters.
- Vowels are a, e, i, o, and u.
Thanks to this site for the challenge idea where it is considered Expert level in JavaScript.
Can be made more efficient and shorter at the cost of readability.