Created
July 4, 2020 06:49
-
-
Save muthhukumar/bae382f92de99d5df93064b829f678c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s1 = input() | |
s2 = input() | |
def checkPalindrome(s): | |
return s == s[::-1] | |
def isSubString(src, s): | |
for i in range(len(src)): | |
for j in range(len(src)): | |
if src[i:j] == s: | |
return True | |
return False | |
def toPalindrome(s): | |
count = 0 | |
if checkPalindrome(s): return s | |
if len(s) % 2 == 0: | |
arr = [i for i in s] | |
k = len(s)//2 | |
for i in range(len(s)//2, 0, -1): | |
arr[k] = s[i-1] | |
k += 1 | |
output = "" | |
count += 1 | |
for i in arr: | |
output += i | |
if checkPalindrome(output): return [output, count] | |
output = "" | |
for i in arr: | |
output += i | |
return [output, count] | |
print(toPalindrome(s1)[1]) | |
print(isSubString(toPalindrome(s1)[0], s2)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment