예제 #1
0
def test_flip():
    s = Stack.from_str('++--+-')
    assert s == [True, True, False, False, True, False]
    assert str(s) == '++--+-'

    s.flip(2)
    assert str(s) == '----+-'
예제 #2
0
def test_quick():
    import random
    for i in range(0, 10000):
        tcount = i % 100
        fcount = 100 - tcount
        tset = [True] * tcount + [False] * fcount
        random.shuffle(tset)
        s1 = Stack(tset)
        s2 = Stack(tset)
        assert s1.solve_regular() == s2.solve_quick()
예제 #3
0
def test_1():
    s = Stack()
    assert s.empty()
    s.push(1)
    assert not s.empty()
    assert s.top() == 1
    s.pop()
    assert s.empty()

    s.push(2)
    assert s.top() == 2
    s.push(3)
    s.push(4)
    s.push(5)
    s.pop()
    assert s.top() == 4
    assert s.top() == 4
    s.pop()
    assert s.top() == 3
    s.pop()
    s.push(6)
    s.push(7)
    s.pop()
    s.pop()
    assert s.top() == 2
    s.pop()
    assert s.empty()
예제 #4
0
def test_regular():
    s = Stack.from_str('--+-')
    n = s.solve_regular()
    assert str(s) == '++++'
    assert n == 3
예제 #5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from solution import Stack

st = Stack()
st.push(1)
print(st.top())
print(st.empty())
#  st.push(1)
#  print(st.pop())