this post was submitted on 15 Jun 2025
14 points (100.0% liked)

LibreByte

159 readers
9 users here now

Tecnologías libres para la comunidad.

Puedes enviar post a esta Comunidad sobre Tecnologías Libres en Español o Inglés.

founded 6 months ago
MODERATORS
top 3 comments
sorted by: hot top controversial new old
[–] Blue_Morpho@lemmy.world 8 points 2 weeks ago

Seems unnecessarily complex. String always has a vowel. It's an i.

[–] Takapapatapaka@lemmy.world 5 points 2 weeks ago

For anyone curious but not wanting to read the article :

The python fastest ways of the base article are mainly using a for loop and using regex (first one is faster on small string, regex becomes faster around 25 characters).

For loop :

def loop_in(s):
    for c in s:
        if c in "aeiouAEIOU":
            return True 
    return False 

Regex :

import re
def regex(s):
    return bool(re.search(r'[aeiouAEIOU]', s))

There are updates to the article, suggesting faster ways. First one uses the find() function, second one swaps the strings of the For Loop method :

def loop_in_perm(s):
        for c in "aeiouAEIOU":
            if c in s:
                return True
        return False
[–] TaviRider@reddthat.com 2 points 2 weeks ago

The recursive solution could have used tail recursion to operate on strings of any size without using O(n) stack space. By just incrementing the string pointer it could do it with just one string buffer too.