Example #1
0
def palChecker(word):
    dq = Dequeue()
    for char in word:
        dq.addRear(char)

    while dq.size() > 1:
        if dq.removeFront() != dq.removeRear():
            return False

    return True
Example #2
0
def palchecker(str):
    d = Dequeue()

    for ch in str:
        d.addRear(ch)

    for _ in range(int(d.size() / 2)):
        if (d.removeFront() != d.removeRear()):
            return False
    return True
Example #3
0
def palin_check(string):
    d=Dequeue()
    for ch in string:
        d.addRear(ch)

    equals=True
    while d.size()>1 and equals:
        if d.removeFront() is d.removeRear():
            pass
        else:
            equals=False

    return equals
def checkPalindrome(input_string):
    dequeue = Dequeue()
    for character in input_string:
        dequeue.addRear(character)

    stillEqual = True
    while (dequeue.size() > 1 and stillEqual):
        first = dequeue.delFront()
        last = dequeue.delRear()
        if first != last:
            stillEqual = False

    return stillEqual
def palindromeChecker(str):
    charDequeue = Dequeue()

    for ch in str:
        charDequeue.addRear(ch)

    stillEqual = True

    while charDequeue.size() > 1 and stillEqual:
        first = charDequeue.removeFront()
        second = charDequeue.removeRear()
        if first != second:
            stillEqual = False
    return stillEqual
def pal_checker(mystr):
    """检查字符串是否为回文字符串,即正序等于逆序字符串"""
    dq = Dequeue()
    mylist = [i for i in mystr]
    indicator = True
    for item in mylist:
        dq.addRear(item)
    for i in range(dq.size() // 2):
        fornt = dq.removeFront()
        rear = dq.removeRear()
        if fornt != rear:
            indicator = False
            break
    return indicator