Ejemplo n.º 1
0
def isPalindrome(string):
    dequeue_string = Dequeue()
    for i in string:
        dequeue_string.addFront(i)

    for i in dequeue_string.items:
        if dequeue_string.removeFront() != dequeue_string.removeRear():
            return False
    return True
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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