예제 #1
0
def eliminar_medio(pilas):
    o = Stack()
    a = pilas.length() / 2
    d = round(a)
    for x in range(1, (d)):
        u = pilas.pop()
        o.push(u)
    t = o.length()
    f = pilas.pop()
    for x in range(1, (t + 1)):
        l = o.pop()
        pilas.push(l)
    return pilas.to_string()
예제 #2
0
def main3():
    pila = Stack()
    pila.push('R')
    pila.push('A')
    pila.push('N')
    pila.push('I <--')
    pila.push('M <--')
    pila.push('I')
    pila.push('L')
    pila.push('E')
    print("Pila sin eliminar datos, ELIMINAR")
    pila.to_string()
    print("Pila Nueva eliminando las letras de en medio que son M y I")
    eliminar(pila, pila.length(), 0)
    pila.to_string()
예제 #3
0
        cuenta_regresiva(num)


def elim_pos_media(pila, size, curr):
    if (pila.is_empty() or curr == size):
        return
    x = pila.peek()
    pila.pop()
    elim_pos_media(pila, size, curr + 1)
    m = (size / 2)
    if m == int(m):
        if (curr != m and curr != (m - 1)):
            pila.push(x)
    else:
        if (curr != int(size / 2)):
            pila.push(x)


if __name__ == '__main__':
    cuenta_regresiva(5)
    pila = Stack()
    pila.push(9)
    pila.push(6)
    pila.push(3)
    pila.push(2)

    print(pila.to_string())
    l = pila.length()

    elim_pos_media(pila, l, 0)