Files
vscode/extensions/copilot/test/scenarios/test-scenario-fix-python/case6.py
T
kieferrmandcopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> 333d9a4053 Hello Copilot
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2025-06-27 11:35:20 +02:00

22 lines
702 B
Python

# Copyright (c) Microsoft Corporation and GitHub. All rights reserved.
def palindrome(s, inner = False):
# given a string of lowercase letters return a palindrome obtained by removing at most one character
# if imposible return None
n = len(s)
i = 0
j = n
while i<=j:
if s[i] == s[j]:
i += 1
j += -1
elif inner == False:
if s[i+1:j+1] == palindrome(s[i+1:j+1],inner = True):
return s[0:i]+s[i+1:j+1]+s[j+1:]
elif s[i:j] == palindrome(s[i:j],inner = True):
return s[0:i]+s[i:j]+s[j+1:]
else:
return None
else:
return None
return s