tag:blogger.com,1999:blog-6314876008291942531.post1058295190115997940..comments2024-01-14T00:36:43.430-08:00Comments on Antonio Gulli's coding playground: How to find largest palindromeUnknownnoreply@blogger.comBlogger2125tag:blogger.com,1999:blog-6314876008291942531.post-86890419297184305942010-06-19T10:57:01.599-07:002010-06-19T10:57:01.599-07:00Construct a matrix with the string and the reverse...Construct a matrix with the string and the reverse of it:<br /><br />def palindromeMatrix(str):<br /> pMatrix = []<br /> strT = str[::-1] <br /> for i in range(len(str)):<br /> tList = []<br /> for j in range(len(str)):<br /> if str[i]==strT[j]:<br /> tList.append(1)<br /> else:<br /> tList.append(0) <br /> pMatrix.append(tList) <br /> print pMatrix<br /><br />m = palindromeMatrix("mammal")<br /><br />The 1's on any of the diagonals on the falling edge correspond to the largest palindrome sequence.Kripa K.S.https://www.blogger.com/profile/07553535660165709216noreply@blogger.comtag:blogger.com,1999:blog-6314876008291942531.post-4881861935477951752010-06-06T10:11:27.746-07:002010-06-06T10:11:27.746-07:00largest palindrome of string length n is 2n, const...largest palindrome of string length n is 2n, constructed by appending to the original string characters in the reverse orderAKhttps://www.blogger.com/profile/03552400896683903007noreply@blogger.com