Skip to content

Instantly share code, notes, and snippets.

@jasonappah
Last active June 25, 2020 02:17
Show Gist options
  • Select an option

  • Save jasonappah/c85af8b84f513d1bb272092c04111c56 to your computer and use it in GitHub Desktop.

Select an option

Save jasonappah/c85af8b84f513d1bb272092c04111c56 to your computer and use it in GitHub Desktop.

Revisions

  1. jasonappah revised this gist Jun 25, 2020. 1 changed file with 2 additions and 16 deletions.
    18 changes: 2 additions & 16 deletions isPalindrome.py
    Original file line number Diff line number Diff line change
    @@ -3,26 +3,12 @@

    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:
    elif str[::1] == str:
    return True
    elif reverse(str) != str:
    else:
    return False


    print (isPalindrome(x))
  2. jasonappah revised this gist Feb 6, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions isPalindrome.py
    Original 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=""):
  3. jasonappah created this gist Feb 6, 2020.
    25 changes: 25 additions & 0 deletions isPalindrome.py
    Original 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))