fork(5) download
  1. def ispalin(s):
  2. return (s == s[::-1])
  3.  
  4. def cpalin(s):
  5. c = 0
  6. for i in range(len(s)):
  7. for j in range(i, len(s)):
  8. if ispalin(s[i:j + 1]):
  9. c += 1
  10. return c
  11.  
  12. print(cpalin(''.join(sorted("abccbaghghghgdfd"))))
  13. print(cpalin(''.join(sorted("oolol"))))
Success #stdin #stdout 0.03s 27704KB
stdin
Standard input is empty
stdout
29
9