Skip to content

@pfctdayelise /
Last active

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
"""Public domain, yo.
See for background.
class Speaker:
def __init__(self, name): = name
self._hasSpoken = False
def __eq__(self, other):
return ==
def __str__(self):
return 'Speaker<{}>'.format(
def speak(self):
self._hasSpoken = True
return '{}!'.format(*3)
def privilege(self):
"""A more accurate implementation is
left as an exercise to the reader.
return self._hasSpoken
class ProgressiveStack:
"""I can't help noting that this is actually a queue
not a stack. ahem.
In real code I would also implement len, contains, etc.
def __init__(self, sortMethod):
@param sortMethod: a function used to sort queue items
such that the first-sorted item will be selected first
(so smaller values = selected earlier).
self._queue = []
self._sortMethod = sortMethod
def __str__(self):
return 'ProgressiveStack<[{}]>'.format(','.join(str(i) for i in self._queue))
def __iter__(self):
return self
def next(self):
bestChoice = self._queue.pop(0)
return bestChoice
def add(self, item):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.