Advertisement
davide1409

palindroma

Jan 5th, 2020
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. def palindroma(s):
  2. #@param s: str
  3. #@return: bool
  4.     lung = len(s)
  5.     if lung<=1:
  6.         return True
  7.     else:
  8.         med = int(lung/2)
  9.         if lung%2==0:
  10.             return s[med] == s[med-1] and palindroma(s[:med]+s[med+1:])
  11.         else:
  12.             return palindroma(s[:med]+s[med+1:])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement