Skip to content

Instantly share code, notes, and snippets.

View futureperfect's full-sized avatar

Erik Hollembeak futureperfect

View GitHub Profile
@futureperfect
futureperfect / FindInBST.java
Last active December 25, 2015 13:09
Find a value within a binary search tree
public class FindInBST {
public static Node<T> findValueInBST(T value, Node<T> root) {
checkNotNull(value);
//terminating condition
if (root == null) {
return null;
}
@futureperfect
futureperfect / find-mode-in-array.txt
Created October 14, 2013 20:11
Find the mode of a sorted array of integers
//Find mode in sorted array
/*
What types? Let's assume int for now.
Bounds on underlying data? No bounds beyond underlying int type
Know anything about the distribution. Nope. Anything and everything, but the array is monotonically increasing.
What bounds on array size? Let's not concern ourselves. Sufficiently
small that we can work with the array in memory.
*/
@futureperfect
futureperfect / CircularArrays.java
Created September 5, 2013 03:29
Determine whether an array is "circular".
package io.tense.interview.arrays;
import static com.google.common.base.Preconditions.checkNotNull;
public class CircularArrays {
/**
* Tests for the the complete "circularity" of an array of integers where
* traversal is performed by taking array[i] and summing the index i and
* value stored in the array to derive a new index.
@futureperfect
futureperfect / edges.csv
Created March 19, 2012 05:25
Sample data for Gephi demonstration
Source Target Type Id Weight Average Degree
1 3 Undirected 1 1.0 1.0
2 10 Undirected 8 1.0 1.0
3 4 Undirected 2 1.0 1.0
4 5 Undirected 3 1.0 1.0
5 10 Undirected 4 1.0 1.0
8 2 Undirected 7 1.0 1.0
8 9 Undirected 11 1.0 1.0
10 1 Undirected 5 1.0 1.0
10 6 Undirected 10 1.0 1.0
@futureperfect
futureperfect / hw1.py
Created February 27, 2012 23:33
Programming assignments for Udacity CS 373 course
# Histogram filter for 2D discrete world
# author: Erik Hollembeak
colors = [['red', 'green', 'green', 'red', 'red'],
['red', 'red', 'green', 'red', 'red'],
['red', 'red', 'green', 'green', 'red'],
['red', 'red', 'red', 'red', 'red']]
measurements = ['green', 'green', 'green', 'green', 'green']
@futureperfect
futureperfect / p10.lisp
Created December 12, 2011 04:14
Generate prime numbers in lisp
(defun divisible-by (number list)
"return true if divisible by an element in the list"
(loop for i in list
thereis (= (mod number i) 0)))
(defun prime-list-generator (current max-value prime-list)
"business end of p10"
(if (= current max-value)
prime-list
(if (divisible-by current prime-list)
@futureperfect
futureperfect / euler.lisp
Created December 8, 2011 08:50
Solutions for Project Euler problems
;(compile-file "euler.lisp")
(defun fib (n)
(if (or (= n 0)
(= n 1))
1
(+ (fib (- n 1))
(fib (- n 2)))))
(defun square (number)
@futureperfect
futureperfect / garbageDetector.py
Created November 18, 2011 23:53
One-off hack for HDAP device 'garbage detector'. For posterity's sake
#!/usr/bin/env python
# encoding: utf-8
"""
garbageDetector.py
Created by Erik Hollembeak on 2009-09-28.
Copyright (c) 2009 Vocalocity. All rights reserved.
"""
import sys
@futureperfect
futureperfect / about.md
Created August 25, 2011 23:56 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@futureperfect
futureperfect / gist:1097449
Created July 21, 2011 15:35
Alan Kay's talk at Creative Think seminar, July 20, 1982
Alan Kay's talk at Creative Think seminar, July 20, 1982
Outline of talk: Metaphors, Magnetic Fields, Snobbery and Slogans
The best way to predict the future is to invent it.
Humans like fantasy and sharing:
Fantasy fulfills a need for a simpler, more controllable world.
Sharing is important - we're all communication junkies. We have an incredible bandwidth