Skip to content

Instantly share code, notes, and snippets.

View terror's full-sized avatar

liam terror

View GitHub Profile
@terror
terror / keybase.md
Created July 28, 2020 00:32
keybase

Keybase proof

I hereby claim:

  • I am terror on github.
  • I am terror (https://keybase.io/terror) on keybase.
  • I have a public key whose fingerprint is F47B 950C BC83 1286 3C74 F850 2D1C 94B5 AE64 3A19

To claim this, I am signing this object:

@terror
terror / template.cpp
Last active September 7, 2020 20:18
c++ template work in progress
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
@terror
terror / guessthedatastructure.py
Created June 28, 2020 06:18
Guess the data structure kattis problem
import sys
for i in sys.stdin:
if i.rstrip() == '':
break
i = int(i)
s = []
q = []
pq = []
@terror
terror / BankQueue.py
Created June 28, 2020 03:29
Solution to bank queue Kattis problem for article
from heapq import heappush, heappop
n, t = list(map(int, input().split()))
people = {}
for i in range(n):
a, b = list(map(int, input().split()))
if b in people:
people[b].append(a)
else:
@terror
terror / PriorityQueue.py
Created June 28, 2020 03:19
Priority queue implementation using list
class PriorityQueue:
def __init__(self):
self.elements = []
# add element to queue
def enqueue(self, element):
self.elements.append(element)
# poll and return element based on priority
# note that this is max pq
@terror
terror / PriorityQueueSTL.py
Created June 27, 2020 22:46
Priority queue in python standard lib
import heapq
items = [1,2,3,4,5]
pq = []
# Push element onto the heap (adding)
# Note that heapq is min heap by default so smallest element gets max priority
for i in items:
heapq.heappush(pq,i)
@terror
terror / QueueSTL.py
Last active June 27, 2020 21:38
Python queue standard lib
import queue
items = [1,2,3,4,5]
q = queue.Queue()
# Enqueue elements
for i in items:
q.put(i)
# Dequeue and return element from the queue
@terror
terror / Queue.py
Last active June 27, 2020 20:10
Queue implementation using list
class Queue:
def __init__(self):
self.elements = []
def enqueue(self, element):
self.elements.insert(0,element)
def dequeue(self):
return self.elements.pop()