Skip to content

Instantly share code, notes, and snippets.

On vacation

t k tahia-khan

On vacation
Block or report user

Report or block tahia-khan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tahia-khan /
Last active Aug 29, 2015
Given a string, prints out all possible permutations using a Trie. Solutions for both with and without duplicate characters. Implemented in python.
__author__ = 'shawli'
#no duplicates
class Trie:
def __init__(self, ch=""): = ch #character = [] #branches
tahia-khan / gobtime.go
Created Jun 9, 2015
Quickly benchmark how long gobbing and ungobbing takes
View gobtime.go
package main
import (
func main() {
tahia-khan / iprange_to_cidrs.go
Created Jul 27, 2015
rough script, still in development
View iprange_to_cidrs.go
package main
import (
func IPToInt(ip string) uint {
tahia-khan /
Last active Aug 29, 2015
get goodreads shelves
import xmltodict
import os
import json
import requests
def request_user_shelves(parms):
p = dict(parms.items() + {"key":os.environ.get("GOODREADS_ACCESS_KEY")}.items())
resp = requests.get("",p)
data_dict = xmltodict.parse(resp.content)
data_dict = data_dict['GoodreadsResponse']['shelves']
View qsort.c
#include <stdio.h>
void qsort(int *X, int L, int U) {
int T, M, i, tmp;
if (L < U) {
T = X[L];
M = L;
for (i = L+1; i < U; i++) {
if (X[i] < T) {
M += 1;
View ll.c
#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
struct Node *prev;
struct Node *next;
int data;
} Node;
class Node:
def __init__(self, data): = data
self.lchild = None
self.rchild = None
def insert(self, key):
if key <
if self.lchild:
tahia-khan / graph.c
Created Nov 8, 2015
adjacency list implementation in c
View graph.c
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#define N 10
typedef struct {
int y;
int weight;
struct Edge *next; /* next in adj list */
class Vertex:
def __init__(self, x):
self.x = x
self.edges = {}
def __str__(self):
return "Vertex %d: %s" % (self.x, self.edges)
tahia-khan /
Last active Nov 9, 2015
given adjacency matrix, detect # of cycles in directed graph
def find_cycles(g, x, path, num_cycles):
if x in path:
return num_cycles
N = len(g[x])
for i in range(N):
if g[x][i]:
You can’t perform that action at this time.