In this Kata, you will be given a string and your task will be to return the length of the longest prefix that is also a suffix. A prefix is the start of a string while the suffix is the end of a string.  For instance, the prefixes of the string `"abcd"` are `["a","ab","abc"]`. The suffixes are `["bcd", "cd", "d"]`. You should not overlap the prefix and suffix.

```Haskell
for example:
solve("abcd") = 0, because no prefix == suffix. 
solve("abcda") = 1, because the longest prefix which == suffix is "a".
solve("abcdabc") = 3. Longest prefix which == suffix is "abc".
solve("aaaa") = 2. Longest prefix which == suffix is "aa". You should not overlap the prefix and suffix
solve("aa") = 1. You should not overlap the prefix and suffix.
solve("a") = 0. You should not overlap the prefix and suffix.
```

All strings will be lowercase and string lengths are `1 <= length <= 500`

More examples in test cases. Good luck!

Difficulty: introductory

Starter code:

def solve(st):
	

Solutions:
def solve(st):
    return next((n for n in range(len(st)//2, 0, -1) if st[:n] == st[-n:]), 0)


def solve(s):
    for i in range(len(s) // 2, 0, -1):
        if s[:i] == s[-i:]:
            return i
    return 0

solve=lambda s:len(__import__('re').match(r'^(.*).*\1$',s).group(1))

def solve(st):
    i = len(st)//2
    while i and not st.endswith(st[0:i]): i -= 1
    return i;


def solve(st):
    attempts = len(st) // 2
    for i in range(attempts, 0, -1):
        if st[:i] == st[-i:]:
            return i
    return 0

def solve(s):
    return max(i for i in range(len(s)//2+1) if s[:i]==s[len(s)-i:])

import math

# The function that will check a prefix and a suffix
def prefix_suffix_check(string, indexIn):
    return string[:indexIn] == string[(indexIn) * -1 : ]

def solve(initial_string):
    
    # Halves and floors the array size
    half_array_size = int(math.floor(len(initial_string) / 2))
    
    # A revese for loop for checking the middle to outer
    for x in range(half_array_size, 0, -1):
        # If the suffix and prefix are equal return the x
        if (prefix_suffix_check(initial_string, x) == True):
            return x
    
    # Else return 0
    return 0


def solve(st):
    prefixes = set()
    sufixes = set()
    pref = ''
    suff = st[1:]
    for i in st[:-1]:
        sufixes.add(suff)
        suff = suff[1:]
        pref += i
        prefixes.add(pref)
    
    for i in sorted(sufixes.intersection(prefixes))[::-1]:
        if len(i) * 2 <= len(st):
            return len(i)
    return 0


def solve(st):
    return max((i for i in range(1, len(st)//2+1) if st[:i] == st[-i:]), default=0)

def solve(st):
    for i in range(len(st)-1,0,-1):
        if not i or len(st) >= 2 * i and st[0:i] == st[-i:]: return i
    return 0