Last active
June 25, 2020 02:17
-
-
Save jasonappah/c85af8b84f513d1bb272092c04111c56 to your computer and use it in GitHub Desktop.
Revisions
-
jasonappah revised this gist
Jun 25, 2020 . 1 changed file with 2 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,26 +3,12 @@ x = "20200202" def isPalindrome(str=""): if str=="": return -1 elif str[::1] == str: return True else: return False print (isPalindrome(x)) -
jasonappah revised this gist
Feb 6, 2020 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ # This is a quick script I wrote to find if a string is a palindrome. # I feel like there's probably a more efficient way of doing this, but it works. To my credit, I did this in about 45 minutes. x = "20200202" def reverse(str=""): -
jasonappah created this gist
Feb 6, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ x = "20200202" def reverse(str=""): if len(str) == 0: print("String is empty") return -1 else: new = "" length = len(str) - 1 while length != 0: new += str[length] length = length - 1 new += str[length] return new def isPalindrome(str=""): if str=="": return -1 elif reverse(str) == str: return True elif reverse(str) != str: return False print (isPalindrome(x))