Skip to content

Instantly share code, notes, and snippets.

@ozgurkaracam
Created January 1, 2016 19:26
Show Gist options
  • Save ozgurkaracam/745aeede9a64be702af2 to your computer and use it in GitHub Desktop.
Save ozgurkaracam/745aeede9a64be702af2 to your computer and use it in GitHub Desktop.
iki stack'ın aynı olup olmadığını kontrol eden program
class Stack:
def __init__(self):
self.alist=[]
def pop(self):
return self.alist.pop()
def push(self,a):
self.alist.append(a)
def show(self):
return self.alist
def peek(self):
return self.alist[len(self.alist)-1]
def isempty(self):
return len(self.alist)==0
def size(self):
return len(self.alist)
def aynimi(a,b):
dengeli=True
if a.size()!=b.size():
return False
else:
if a.isempty() and b.isempty():
return True
else:
while a.isempty()==False and b.isempty()==False:
if a.pop()!=b.pop():
dengeli=False
break
return dengeli
s=Stack()
a=Stack()
s.push('a')
s.push('b')
print (aynimi(s,a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment