Skip to content

Instantly share code, notes, and snippets.

@andreis
Created March 26, 2014 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreis/9787063 to your computer and use it in GitHub Desktop.
Save andreis/9787063 to your computer and use it in GitHub Desktop.
s1 = []
s2 = []
def enq(val):
global s1, s2
if len(s1) == 0:
s1.append(val)
else:
s2.append(val)
while len(s1) > 0:
s2.append(s1.pop())
s1, s2 = s2, s1
def empty():
return len(s1) == 0 and len(s2) == 0
def deq():
if empty():
print("he's dead, jim")
return s1.pop()
size = 5
for i in range(size):
enq((i+1)*10)
for i in range(size):
print(deq())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment