Skip to content

Instantly share code, notes, and snippets.

@austa
Created November 21, 2013 19:56
Show Gist options
  • Save austa/7588458 to your computer and use it in GitHub Desktop.
Save austa/7588458 to your computer and use it in GitHub Desktop.
class Queue:
def __init__(self):
self.liste = []
def enqueue(self,eleman):
self.liste.insert(0,eleman)
def dequeue(self):
return self.liste.pop()
def size(self):
return len(self.liste)
def peek(self):
return self.liste[-1]
def isEmpty(self):
return self.liste == []
def mzk_patato(gelen_liste,N):
q = Queue()
counter = 0
while len(gelen_liste) > counter:
q.enqueue(gelen_liste[counter])
counter += 1
while q.size() > 1:
for i in range(1,N):
q.enqueue(q.dequeue())
son_cocuk = q.peek()
#print son_cocuk
mzk_degeri = son_cocuk[1]
if mzk_degeri != 0 and mzk_degeri != 0:
son_cocuk[1] -= 1
else:
q.dequeue()
return q.peek()
liste = [["Ali",2],["Veli",2],["Fatih",1],["Aykut",2],["Halit",1],["Alaattin",2]]
print mzk_patato(liste,3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment