Skip to content

Instantly share code, notes, and snippets.

@abhijithanilkumar
Created August 3, 2017 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhijithanilkumar/6119122895cd729bb5b8649ba24dd1f7 to your computer and use it in GitHub Desktop.
Save abhijithanilkumar/6119122895cd729bb5b8649ba24dd1f7 to your computer and use it in GitHub Desktop.
question 6
from itertools import groupby
def splitWithIndices(a, c=' '):
p=0
for k,g in groupby(s, lambda x:x:==c):
q=p + sum(1 for i in g)
if not k:
yield p,q
p=q
def calc_palindrome(a):
b = list(splitWithIndices(a))
for i in b:
n = a[i[0]:i[1]]
if str(n).lower == str(n)[::-1].lower():
print n, i[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment