Last active
November 3, 2017 10:31
-
-
Save m0r13/c1a402851cd80e8b1deff700cc57cc6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
class GeorgianQueue: | |
def __init__(self, g, *args, **kwargs): | |
self.queue = [] | |
self.g = g | |
def size(self): | |
return len(self.queue) | |
def empty(self): | |
return self.size() == 0 | |
def put(self, item): | |
if random.random() < self.g: | |
self.queue.insert(1, item) | |
else: | |
self.queue.append(item) | |
def get(self): | |
return self.queue.pop(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment