Skip to content

Instantly share code, notes, and snippets.

@x1001000
Created February 3, 2022 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x1001000/5978b4d1a74ed7421d8276c626512063 to your computer and use it in GitHub Desktop.
Save x1001000/5978b4d1a74ed7421d8276c626512063 to your computer and use it in GitHub Desktop.
class Solution:
def isHappy(self, n: int) -> bool:
cycle = []
while n not in cycle and n != 1:
cycle.append(n)
n = sum(map(lambda x: int(x)**2, str(n)))
return True if n == 1 else False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment