Created
March 13, 2018 23:33
-
-
Save dogac00/1c63f187c62fe32c7a94a1ac3b4aff55 to your computer and use it in GitHub Desktop.
Palindrome chain length @codewars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_palindrome(a): | |
return str(a) == str(a)[::-1] | |
def palindrome_chain_length(n): | |
steps=0 | |
while(check_palindrome(n)!=True): | |
n=n+int(str(n)[::-1]) | |
steps+=1 | |
return steps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment