Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_palindrome(s):
- l = len(s)
- for i in range(l//2):
- if s[i] != s[-1-i]:
- return False
- return True
- import random
- class PalindromesClass:
- def __init__(self):
- self.chcount = 0
- self.palindromes = []
- self.count = 0
- self.n = str(self.count)
- def check_palindromes(self):
- self.not_pals = 0
- for _ in range(100000):
- if not is_palindrome("".join([str(x) for x in range(random.randint(2, 5))])):
- self.not_pals += 1
- if self.not_pals == 100000:
- self.chcount += 1
- while self.count < 100000:
- if self.n == self.n[::-1] is True:
- self.palindromes.append(self.n)
- self.count += 1
- self.n = str(self.count)
- else:
- self.count += 1
- self.n = str(self.count)
- if all(is_palindrome(pal) for pal in self.palindromes):
- self.chcount += 1
- return self.chcount
- if __name__ == "__main__":
- print("YES" if PalindromesClass().check_palindromes() == 2 else "NO")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement