Skip to content

Instantly share code, notes, and snippets.

View fitzk's full-sized avatar

Kayla Fitzsimmons fitzk

View GitHub Profile
@fitzk
fitzk / agency-list.py
Last active January 31, 2017 23:39
HackerRank: Python3 Agency List class and builder function.
class AgencyList:
def __init__(self):
self.verticies = list()
self.edges = dict()
# dict of lists
def initEdge(self, v1, v2):
if not v1 in self.edges:
self.edges[v1] = list()
if not v2 in self.edges:
self.edges[v2] = list()
@fitzk
fitzk / agency-list-jtm.js
Last active January 31, 2017 23:46
HackerRank: input processing, Agency List class, and logic to solve problem
// input processing
function createMatrix(rows) {
// regex to filter only digits
let re = /[0-9]/
let matrix = []
for ( let row of rows ) {
matrix.push( row.split(' ')
.filter( i => re.test(i) === true)
.map( i => parseInt(i) )
.sort( (a,b) => a - b ) );
@fitzk
fitzk / merge-sort.py
Last active January 31, 2017 23:47
HackerRank: merge sort function https://repl.it/EVhs/13
# MergeSort Recursive Solution
# Python
def Merge(left, right, original):
left_len = len(left)
right_len = len(right)
left_index = 0
right_index = 0
original_index = 0
@fitzk
fitzk / trends.py
Created February 2, 2017 02:49
Data Processing: Given an array of integers with fixed positions (ie, stocks), this script calculates trends based on positive, negative, or plateaued growth. This function excludes information about the relationship between trends, though some relationships can be easily inferred.
@fitzk
fitzk / recursive-permutations.js
Last active February 7, 2017 00:55
Find all permutations of a string using recursion.
function getPermutations(string, p) {
if(string.length <= 1) return new Set(string)
let allCharsExceptLast = string.slice(0, -1)
let lastChar = string[string.length - 1]
let permutationsOfAllCharsExceptLast = getPermutations(allCharsExceptLast);
let permutations = new Set()
for(let perm of permutationsOfAllCharsExceptLast) {
@fitzk
fitzk / trump_tweets.py
Last active February 8, 2017 22:18
Generates a JSON object of Donald Trump's tweets and their associated meta-data.
import tweepy
import json
CONSUMER_KEY = # your consumer key
CONSUMER_SECRET = # your consumer secret
ACCESS_KEY = # your access key
ACCESS_SECRET = # your access secret
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
@fitzk
fitzk / max-sum.js
Last active February 9, 2017 19:23
Maximum Sub Array Contiguous, a Greedy Implementation
const trivialCase = [ 5, -6, 7, 12, -3, 0, -11, -6 ];
function sumValues(a, b) {
return a + b
}
function sumSubArraysStartingAtValue(arr, i) {
let sums = []
for(let j = i+1; j < arr.length; j++ ) {
@fitzk
fitzk / twitter-proxy.js
Last active February 17, 2017 16:57
Webtask & Twitter application authorization example.
/*
* docs
* Webtask - https://webtask.io
* Twitter - https://dev.twitter.com/oauth/application-only
* note
* Here is an easy way to base64 your consumer key and consumer secret
* from the command line:
*
* echo -n "CONSUMER_KEY:CONSUMER_SECRET" | base64
*