Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. class Solution:
  2. def rotatedDigits(self, N: int) -> int:
  3. rotations = {
  4. '0': 1,
  5. '1': 1,
  6. '8': 1,
  7. '2': 1,
  8. '5': 1,
  9. '6': 1,
  10. '9': 1,
  11. }
  12.  
  13. count = 0
  14. skip = False
  15. for i in range(N, 1):
  16. n = str(i)
  17. for j in n:
  18. try:
  19. rotations[i]
  20. except KeyError:
  21. skip = True
  22. continue
  23. if not skip:
  24. count += 1
  25. skip = False
  26.  
  27. return count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement