Skip to content

Instantly share code, notes, and snippets.

View say4n's full-sized avatar
💻

Sayan Goswami say4n

💻
View GitHub Profile
@say4n
say4n / heap.py
Created May 6, 2020 12:34
A simple min/max heap implementation.
#! /usr/bin/env python3
class Heap:
"""
Min-heap implementation.
"""
def __init__(self, ordering='min'):
self.data = []
assert str.lower(ordering) in ('min', 'max')
self.ordering = ordering
@say4n
say4n / trie.py
Last active March 26, 2020 15:36
A Trie implementation in Python3.
#! /usr/bin/env python3
from typing import Any, Dict
class Node:
def __init__(self, value=None):
self.value: Any = value
self.children: Dict[str, Node] = {}
class Trie:
@say4n
say4n / hashmap.py
Last active March 26, 2020 07:42
A very crude, inefficient HashMap implementation.
#! /usr/bin/env python3
import random
class HashMap:
def __init__(self, num_buckets=100):
self.num_buckets = num_buckets
self.buckets = [[] for _ in range(num_buckets)]
def put(self, key, val):
@say4n
say4n / backprop.ipynb
Created January 31, 2020 20:05
Hacker's guide to Neural Networks in Python!
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@say4n
say4n / Makefile
Last active September 13, 2019 06:04
heap, heap-sort implementation in C++
.PHONY: all
all: heap
heap: heap.cpp
$(CXX) -std=c++11 heap.cpp

Keybase proof

I hereby claim:

  • I am say4n on github.
  • I am sayan (https://keybase.io/sayan) on keybase.
  • I have a public key ASAMjHcD5qnE2nmA3mCV6PgDpvLNkRSE1NHJpfHlapyf-wo

To claim this, I am signing this object:

@say4n
say4n / Makefile
Last active September 4, 2019 18:38
semaphore implementation in c++
.PHONY: all
all: procA procB
procA: processA.cpp
mkdir -p build
$(CXX) -std=c++11 processA.cpp -o build/procA.out
procB: processB.cpp
mkdir -p build
@say4n
say4n / gradient.py
Created August 29, 2019 13:14
numerical gradient for arbitrary functions that have codomain as the set of all real numbers
#! /usr/bin/env python3
from copy import deepcopy
def median(l):
l = sorted(l)
if len(l) % 2 == 0:
return (l[len(l)//2] + l[len(l)//2 - 1])/2
@say4n
say4n / database.py
Last active August 28, 2019 15:06
a simple relational algebra emulator
#! /usr/bin/env python3
class Relation:
def __init__(self, *, attributes=None, name=None):
self.attributes = attributes
self.name = name
self.rows = []
@say4n
say4n / ast.py
Last active August 28, 2019 05:17
parser to parse a basic if else construct (with nesting)
#! /usr/bin/env python3
class Node:
"""abstract base class for Nodes"""
def __init__(self):
pass
def __repr__(self):
raise NotImplementedError()