Gentlemen, there was a question on the prefix function for the ILC algorithm. Can someone pick up a string in which the code below on the python will display the wrong value of the prefix function? As an example, cited the string "abcdabcd", which is processed correctly. Thank.

def prefix(S): p=[0]*(len(S)+1) for i in range(1, len(S)): k=p[i-1] while k>0 and S[i]!=S[k]: k=0 #здесь должно быть k=p[k-1], но подобрать строку надо для k=0 if S[i]==S[k]: k+=1 p[i]=k return k S="abcdabcd" print(prefix(S)) 
  • print(prefix('000_0000') ? - MaxU
  • Thank you very much. - lev83

0