Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. def is_palindrome(s):
  2. l = len(s)
  3.  
  4. for i in range(l//2):
  5. if s[i] != s[-1-i]:
  6. return False
  7. return True
  8.  
  9.  
  10. import random
  11.  
  12.  
  13. class PalindromesClass:
  14. def __init__(self):
  15. self.chcount = 0
  16. self.palindromes = []
  17. self.count = 0
  18. self.n = str(self.count)
  19.  
  20. def check_palindromes(self):
  21. self.not_pals = 0
  22. for _ in range(100000):
  23. if not is_palindrome("".join([str(x) for x in range(random.randint(2, 5))])):
  24. self.not_pals += 1
  25.  
  26. if self.not_pals == 100000:
  27. self.chcount += 1
  28.  
  29. while self.count < 100000:
  30. if self.n == self.n[::-1] is True:
  31. self.palindromes.append(self.n)
  32. self.count += 1
  33. self.n = str(self.count)
  34. else:
  35. self.count += 1
  36. self.n = str(self.count)
  37. if all(is_palindrome(pal) for pal in self.palindromes):
  38. self.chcount += 1
  39.  
  40. return self.chcount
  41.  
  42.  
  43. if __name__ == "__main__":
  44. print("YES" if PalindromesClass().check_palindromes() == 2 else "NO")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement