Open projectPythonator opened 4 years ago
sorry for the bad formatting idk how to link the file with line https://github.com/stevenhalim/cpbook-code/blob/master/ch6/sa_lcp.py
You're right that m
is missing as a parameter. Same for n
but it can be deduced from len(sa)
. Also lcs
should be changed to max_lcp
or vice versa.
To show specific line see https://docs.github.com/en/github/managing-your-work-on-github/creating-a-permanent-link-to-a-code-snippet. In this case it's
https://github.com/stevenhalim/cpbook-code/blob/0ba81b4c31519f1109a147063dbca0a7bfa17c91/ch6/sa_lcp.py#L88-L96
which would be rendered as https://github.com/stevenhalim/cpbook-code/blob/0ba81b4c31519f1109a147063dbca0a7bfa17c91/ch6/sa_lcp.py#L88-L96
in this file it does not seem that we are using globals so in this code m is missing as a parameter (n is also missing but in main its defined as just len of the string) def longest_common_substring(sa, lcp): idx = 0 max_lcp = -1 for i in range(1, n): if (sa[i] < m) != (sa[i-1] < m) and lcp[i] > lcs: max_lcp = lcp[i] idx = i return (max_lcp, idx)