Skip to content

Instantly share code, notes, and snippets.

View seanpont's full-sized avatar

Sean Pont seanpont

View GitHub Profile
@seanpont
seanpont / MaxWithinWindow.java
Created August 18, 2013 03:45
MaxWithinWindow.java allows you to query for the maximum within the last n items added.
package com.seanpont.structs;
import java.util.ArrayDeque;
import java.util.Deque;
/**
* Add items. Query which is the largest within the last n additions.
* User: spont200
* Date: 8/17/13
*/
@seanpont
seanpont / InstrumentedArrayDeque.java
Last active December 21, 2015 05:49
MaxWithinWindowTest.java
package com.seanpont.structs;
import java.util.ArrayDeque;
/**
* User: spont200
* Date: 8/17/13
*/
public class InstrumentedArrayDeque<T> extends ArrayDeque<T> {
@seanpont
seanpont / menuPicker.go
Last active December 19, 2015 02:48
A fun problem: given a menu with items and associated costs, and some desired combination of items, find the optimal choice of items on the menu to minimize the total cost. This is an optimization problem for which we may use boolean satisfiability. This solution is brute force, and there are clearly some optimizations one could take. In any cas…
// menupicker.go
package main
import (
"fmt"
"strconv"
"strings"
)
const MAX_COST = 1 << 20
@seanpont
seanpont / Partition.java
Created May 24, 2013 17:51
Partition a number. For example, partition(5) = [ [5], [4,1], [3,2], [3,1,1], [2,2,1], [2,1,1,1], [1,1,1,1,1] ]. For more information on partions, see http://en.wikipedia.org/wiki/Partition_(number_theory)
package com.seanpont.partition;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@seanpont
seanpont / SaxRssHandler.java
Created November 14, 2012 01:54
Concise, effective SAX Parser for RSS Feeds
package com.seanpont.rss;
import java.util.Arrays;
import java.util.HashMap;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
/**
p0h+nMRcc+9eoqFm5vL0HduVfwsEiqo6qkHYf2g5qFS6UTpUv4f5tMHZSMkI2VDbHIqTy381Xs3fL0OGjRJEdQ8KvgVe915EL6qrvKmJ1xpK08kvtSRZwzUjwpKg/qyDFPeLftZF5dZemaZxMb8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