Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Palindrome Index Custom checker logic
result = 1
for inp, outp in zip(inps, outps):
    #VALIDATION
    inp = inp.strip()
    outp = outp.strip()
    if outp.isdigit() or (outp.startswith('-') and outp[1:].isdigit()):
        outp = int(outp)
    else:
        result = 0
        break
    if outp<-1 and outp>=len(inp):
        result = 0
        break
    if outp==-1:
        temp = list(inp)
    else:
        temp=inp[0:outp]+inp[outp+1:]
    if temp != temp[::-1]:  #temp[::-1] is reverse of temp 
        result = 0
        break
@ttowncompiled

This comment has been minimized.

Copy link

@ttowncompiled ttowncompiled commented Jun 26, 2015

if outp<-1 and outp>=len(inp):

Isn't this a False statement? Since len(inp) >= 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment