LC 0788 [M] Rotated Digits - ALawliet/algorithms GitHub Wiki

class Solution:
    def rotatedDigits(self, n: int) -> int:
        def good(x):
            rotated = False
            y = None
            while x > 0:
                y = x % 10
                print(y)
                if y in (0,1,8):
                    pass
                elif y in (2,5,6,9):
                    rotated = True
                else:
                    return False
                x //= 10
            return rotated
        
        count = 0
        for i in range(1, n+1):
            if good(i):
                count += 1
        return count
class Solution:
    def rotatedDigits(self, N: int) -> int:
            count = 0
            for d in range(1, N+1):
                d = str(d)
                # if '3' in d or '4' in d or '7' in d:
                if any(map(lambda x: x in d, ['3','4','7'])):
                    continue
                # if '2' in d or '5' in d or '6' in d or '9' in d:
                if any(map(lambda x: x in d, ['2','5','6','9'])):
                    count += 1
            return count
class Solution:
    def rotatedDigits(self, N: int) -> int:
            count = 0
            for d in range(1, N+1):
                d = str(d)
                # if '3' in d or '4' in d or '7' in d:
                if any(map(lambda x: x in d, ['3','4','7'])):
                    continue
                # if '2' in d or '5' in d or '6' in d or '9' in d:
                if any(map(lambda x: x in d, ['2','5','6','9'])):
                    count += 1
            return count