788. 旋转数字

https://blog.csdn.net/qq_21162871/article/details/80380321

https://blog.csdn.net/fuxuemingzhu/article/details/79378135

# 可以总结出以下的要求:
#
# 该数字中不含[3, 4, 7],否则其倒影不是数字。
# 该数字中必须包含[2, 5, 6, 9]中的至少一个,否则倒影和原数字相同
# 包含[2, 5, 6, 9]中的至少一个==[1,8,0]不构成全部的数字

class Solution(object):
    def rotatedDigits(self, N):
        """
        :type N: int
        :rtype: int
        """
        str1 = ''
        rs = 0
        for i in range(1,N+1):
            # print(i)
            str1 = str(i)
            if (str1.count('3')==0 and str1.count('4')==0 and str1.count('7')==0):
                if (str1.count('1')+str1.count('8')+str1.count('0')!=len(str1)):
                    rs += 1
        return rs

猜你喜欢

转载自blog.csdn.net/weixin_31866177/article/details/83032236