Farz0l1x

Untitled

Jan 22nd, 2024
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. def f(n):
  2.     s = []
  3.     while n > 0:
  4.         s.append(n % 16)
  5.         n //= 16
  6.     s = s[::-1]
  7.     return s
  8. count = 0
  9. for i in range(100, 1000):
  10.     n = f(i)
  11.     s = n
  12.     n.sort()
  13.     n = n[::-1]
  14.     if s == n:
  15.         count += 1
  16. for i in range(10000, 100000):
  17.     n = f(i)
  18.     s = n
  19.     n.sort()
  20.     n = n[::-1]
  21.     if s == n:
  22.         count += 1
  23. print(count)
Advertisement
Add Comment
Please, Sign In to add comment