#202 ac

def nextSquareSum(x):
    tmparr = []
    while x >= 10:
        tmparr.append(x%10)
        x/=10
    tmparr.append(x)
    return sum([i*i for i in tmparr])

class Solution(object):
    def isHappy(self, n):
        """
        :type n: int
        :rtype: bool
        """
        tmpSet= set() # determine if it get into a cycle
        x = n
        while True:
            if x == 1:
                return True
            if x in tmpSet:
                return False
            tmpSet.add(x)
            x = nextSquareSum(x)



9075391a4fe75da4ffa78b0cb788a418d093b51c
<mask token>

<mask token>


class Solution(object):
    <mask token>

<mask token>


class Solution(object):

    def isHappy(self, n):
        """
        :type n: int
        :rtype: bool
        """
        tmpSet = set()
        x = n
        while True:
            if x == 1:
                return True
            if x in tmpSet:
                return False
            tmpSet.add(x)
            x = nextSquareSum(x)

def nextSquareSum(x):
    tmparr = []
    while x >= 10:
        tmparr.append(x % 10)
        x /= 10
    tmparr.append(x)
    return sum([(i * i) for i in tmparr])


class Solution(object):

    def isHappy(self, n):
        """
        :type n: int
        :rtype: bool
        """
        tmpSet = set()
        x = n
        while True:
            if x == 1:
                return True
            if x in tmpSet:
                return False
            tmpSet.add(x)
            x = nextSquareSum(x)

#202 ac

def nextSquareSum(x):
    tmparr = []
    while x >= 10:
        tmparr.append(x%10)
        x/=10
    tmparr.append(x)
    return sum([i*i for i in tmparr])

class Solution(object):
    def isHappy(self, n):
        """
        :type n: int
        :rtype: bool
        """
        tmpSet= set() # determine if it get into a cycle
        x = n
        while True:
            if x == 1:
                return True
            if x in tmpSet:
                return False
            tmpSet.add(x)
            x = nextSquareSum(x)


