This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'shawli' | |
#no duplicates | |
class Trie: | |
def __init__(self, ch=""): | |
self.ch = ch #character | |
self.br = [] #branches |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/gob" | |
"fmt" | |
"os" | |
"time" | |
) | |
func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
"strconv" | |
"strings" | |
) | |
func IPToInt(ip string) uint { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("https://www.goodreads.com/shelf/list.xml",p) | |
data_dict = xmltodict.parse(resp.content) | |
data_dict = data_dict['GoodreadsResponse']['shelves'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct Node { | |
struct Node *prev; | |
struct Node *next; | |
int data; | |
} Node; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
def __init__(self, data): | |
self.data = data | |
self.lchild = None | |
self.rchild = None | |
def insert(self, key): | |
if key < self.data: | |
if self.lchild: | |
self.lchild.insert(key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# graph.py | |
class Vertex: | |
def __init__(self, x): | |
self.x = x | |
self.edges = {} | |
def __str__(self): | |
return "Vertex %d: %s" % (self.x, self.edges) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_cycles(g, x, path, num_cycles): | |
if x in path: | |
num_cycles+=1 | |
return num_cycles | |
path.append(x) | |
N = len(g[x]) | |
for i in range(N): | |
if g[x][i]: |
OlderNewer