Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/scenarios/test-scenario-fix-python/case10.py
13397 views
1
# Copyright (c) Microsoft Corporation and GitHub. All rights reserved.
2
3
def palindrome(s, inner = False):
4
# given a string of lowercase letters return a palindrome obtained by removing at most one character
5
# if imposible return None
6
n = len(s)
7
i = 0
8
j = n-1
9
while i<=j:
10
if s[i] == s[j]:
11
i += 1
12
j += -1
13
elif inner == False:
14
if s[i+1:j+1] == palindrome(s[i+1:j+1],inner = True):
15
return s[0:i]+s[i+1:j+1]+s[j+1:]
16
elif s[i:j] == palindrome(s[i:j],inner = True):
17
return s[0:i]+s[i:j]+s[j+1:]
18
else:
19
return None
20
else:
21
return None
22
return None
23