 Kokoma fonction pona koluka sous-chaîne commune ya molayi ya ba chaînes mibale.
Tala fonction ya Python oyo okoki kosalela pona koluka sous-chaîne commune ya molayi ya ba chaînes mibale: ```python def longest_common_substring(string1, string2): m = len(string1) n = len(string2) # Sala tableau pona kobomba ba longueurs ya ba suffixes communs ya milayi ya ba sous-chaînes maxLength = 0 suka = 0 longueur = [[0 pona j na range(n + 1)] pona i na range(m + 1)] # Luka ba sous-chaînes communes pona i na range(1, m + 1): mpo na j na intervalle(1, n + 1): soki molongo1[i - 1] == molongo2[j - 1]: bolai[i][j] = bolai[i - 1][j - 1] + 1 # kosala mikolo oyo bolai ya likolo mpe index ya mbano soki maxLength < bolai[i][j]: maxLength = bolai[i][j] nsuka = i - 1 mosusu: bolai[i][j] = 0 # zongisa oyo eleki molai sous-string commun return string1[end - maxLength + 1:end + 1] ``` Tala ndakisa ya ndenge nini okoki kosalela fonction oyo: ```python string1 = "abcdefabcdefg" string2 = "xyzabcdefwabc" longest_common = longest_common_substring(string1, string2 ) imprimer(molai_ya mingi) # "abcdef" ```