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
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 */
@tahia-khan
tahia-khan / gist:16b5fdd66b1544bd335f84a46af4bb63
Created Sep 5, 2017 — forked from bsmartt13/gist:efa02c40ea12c09d9c3a
OTX IP Reputation download links (updated hourly)
View gist:16b5fdd66b1544bd335f84a46af4bb63
https://reputation.alienvault.com/reputation.generic.gz
https://reputation.alienvault.com/reputation.generic
https://reputation.alienvault.com/reputation.data
https://reputation.alienvault.com/reputation.snort.gz
https://reputation.alienvault.com/reputation.snort
https://reputation.alienvault.com/reputation.iptables.gz
https://reputation.alienvault.com/reputation.iptables
https://reputation.alienvault.com/reputation.squid.gz
https://reputation.alienvault.com/reputation.squid
https://reputation.alienvault.com/reputation.unix.gz
View backtrack_permutations.py
def backtrack(A, k, N):
""" General backtrack algorithm which enumerates all possible solutions """
if is_a_solution(A, k, N):
process_solution(A, k, N)
return
k = k + 1
candidates = construct_candidates(A, k, N)
for c in candidates:
View redbluebluered.py
def rebluebluered(s, pattern):
return search(s, pattern, dict())
def search(left, pattern, matches):
if (not pattern and left) or (pattern and not left):
return False
if not pattern and not left:
return True
View priority_queue.py
class PQ:
"""
Priority queue implemented as a heap (minheap).
"""
def __init__(self ):
self.heap = [0]
self.size = 0
def insert(self, x):
View qsort.py
def qsort(A, L, U):
if L < U:
T = A[L]
M = L #pivot
for i in range(L+1, U):
if A[i] < T:
M += 1
tmp = A[M]
A[M] = A[i]
A[i] = tmp
View permutations.py
from collections import deque
def permutations(word):
if len(word) == 1:
return [word]
perms = permutations(word[1:])
c = word[0]
res = []
View djikstra.py
import heapq
def djikstra(graph, s, z):
dist = {s:0}
pred = {s:None}
visited = {}
q = []
heapq.heappush(q, s)
while q:
View ATaleOfThreeCities.py
from math import sqrt, pow
class ATaleOfThreeCities:
AB = 1
BC = 2
CA = 3
def __init__(self, min1=999, min2=999):
self.min1 = min1
View qsort.py
def qsort(A, L, U):
if L < U:
P = A[L]
W = L
for i in range(L, U):
if A[i] < P:
W += 1
tmp = A[i]
A[i] = A[W]
A[W] = tmp
You can’t perform that action at this time.