Skip to content

Instantly share code, notes, and snippets.

View paranoiacblack's full-sized avatar

Chris Manghane paranoiacblack

View GitHub Profile
@paranoiacblack
paranoiacblack / test.py
Created January 10, 2017 02:54
Krishna errors
street_type_re = re.compile(r'\b\S+\.?$', re.IGNORECASE)
expected = ["Street", "Avenue", "Boulevard", "Drive", "Court", "Place", "Square", "Lane", "Road",
"Trail", "Parkway", "Commons"]
# UPDATE THIS VARIABLE
mapping = { "St": "Street",
"St.": "Street",
"Ave": "Avenue",
@paranoiacblack
paranoiacblack / hash_family_ex1.h
Created June 3, 2013 16:42
CS14 SI Lab 6 Solutions
#ifndef __HASH_FAMILY_H__
#define __HASH_FAMILY_H__
class HashFamily {
public:
// Self-contained Prime numbers
enum Prime {
A = 54059,
B = 76963,
C = 68969
@paranoiacblack
paranoiacblack / distance_heap.h
Created June 3, 2013 09:18
CS14 SI Lab Session 9 Solutions
#ifndef __DISTANCE_HEAP_H__
#define __DISTANCE_HEAP_H__
#include "heap.h"
#include "node.h"
#include <utility>
using std::pair;
struct DistancePair {
@paranoiacblack
paranoiacblack / main.cpp
Created June 3, 2013 05:40
CS14 SI Lab Session 8 Solutions
#include "undirected_graph.h"
#include <string>
#include <cassert>
using std::string;
int main() {
UndirectedGraph<int> g;
g.addVertex(1);
g.addVertex(2);
@paranoiacblack
paranoiacblack / edge.h
Created May 30, 2013 20:52
CS14 Lab Session 9 Code
#ifndef __EDGE_H__
#define __EDGE_H__
#include "node.h"
struct Edge {
Node* from;
Node* to;
double weight;
@paranoiacblack
paranoiacblack / ex4.cpp
Created May 16, 2013 19:53
CS14 SI Lab Session 7
#include "graph_node.h"
#include <vector>
using std::vector;
bool is_connected(vector<GraphNode*> nodes) {
for (unsigned i = 0; i < nodes.size(); ++i) {
for (unsigned j = 0; j < nodes.size(); ++j) {
if (i == j) {
continue;
@paranoiacblack
paranoiacblack / avl.h
Created May 3, 2013 04:17
CS14 Lab5 Solution
#ifndef __AVL_H__
#define __AVL_H__
#include <iostream>
#include <list>
#include <algorithm>
template<typename T>
class Avl {
private:
@paranoiacblack
paranoiacblack / dictionary.cpp
Created April 25, 2013 22:52
CS14 Lab 4 Solution
#include "tree.h"
#include <utility>
#include <string>
using namespace std;
struct DictionaryNode {
pair<string, string> word_meaning_pair;
DictionaryNode(const string& word, const string& meaning)
@paranoiacblack
paranoiacblack / ex1.cpp
Created April 19, 2013 06:24
CS14 SI Lab 3 solutions
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool binary_search_rec(const vector<int>& v, unsigned start, unsigned end, int target) {
int middle = (start + end) / 2;
if (start == end) {
return false;