Skip to content

Instantly share code, notes, and snippets.

@m0r13
Last active November 3, 2017 10:31
Show Gist options
  • Save m0r13/c1a402851cd80e8b1deff700cc57cc6e to your computer and use it in GitHub Desktop.
Save m0r13/c1a402851cd80e8b1deff700cc57cc6e to your computer and use it in GitHub Desktop.
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