algorithms/string_searching/algorithm.py
def naive(t: str, w: str) -> list:
    """
    Naive method for string searching.
    :param t: text to search the word in.
    :param w: word to be searched.
    :return: list of start indexes.
    """
    n = len(t)
    m = len(w)
    indexes = []

    d = 0
    i = 0

    while d < n - m:
        if i == m:  # If a match is found.
            indexes.append(d)
            i = 0
            d += 1

        if t[d + i] == w[i]:
            i += 1
        else:
            i = 0
            d += 1

    return indexes

    Naive method for string searching.
    :param t: text to search the word in.
    :param w: word to be searched.
    :return: list of start indexes.
    
Naive method for string searching.
Naive method for string searching .
def naive(t: str, w: str) -> list:
    n = len(t)
    m = len(w)
    indexes = []
    d = 0
    i = 0
    while d < n - m:
        if i == m:  
            indexes.append(d)
            i = 0
            d += 1
        if t[d + i] == w[i]:
            i += 1
        else:
            i = 0
            d += 1
    return indexes
def naive ( t : str , w : str ) -> list : n = len ( t ) m = len ( w ) indexes = [ ] d = 0 i = 0 while d < n - m : if i == m : indexes . append ( d ) i = 0 d += 1 if t [ d + i ] == w [ i ] : i += 1 else : i = 0 d += 1 return indexes
Naive method for string searching.
Naive method for string searching .
"""
    Naive method for string searching.
    :param t: text to search the word in.
    :param w: word to be searched.
    :return: list of start indexes.
    """ # If a match is found.
list of start indexes.
list of start indexes .
t
str
text to search the word in.
text to search the word in .
w
str
word to be searched.
word to be searched .