```
class Solution:
# @param {integer} n
# @return {boolean}
def isHappy(self, n):
def calc(num):
sum_num = 0
num = str(num)
for i in num:
sum_num = int(i) * int(i) + sum_num
return sum_num
l = []
res = None
while True:
n = calc(n)
if n in l:
return False
elif n == 1:
return True
l.append(n)
```