Skip to content

Instantly share code, notes, and snippets.

View adamhaile's full-sized avatar

Adam Haile adamhaile

View GitHub Profile
@adamhaile
adamhaile / GoatsWolvesAndLions.js
Last active August 29, 2015 14:02
Speeding Up Goats, Wolves and Lions By 18,800x
// Optimizing Javascript Implementation of Goats, Wolves and Lions
// Original fun puzzle from http://unriskinsight.blogspot.com/2014/06/fast-functional-goats-lions-and-wolves.html
//
// Strategy:
// 1 - we know that each move reduces the total population by 1, so the optimal
// solution will be the one with the least moves. So we'll progressively
// explore solutions of greater depth until we find a stable forest.
// 2 - since each move removes at most one from each animal, any solution
// must have a depth at least as great as the minimum of the initial animal counts.
// 3 - the order of moves doesn't matter. to be more precise, if there is
@adamhaile
adamhaile / NewCo.TwitterAnalysis.Idiomatic.fs
Created April 24, 2014 19:04
TriNUG F# / Data Analytics Twitter Analysis using idiomatic functional style
namespace NewCo.TwitterAnalysis.Idiomatic
open System
type tweet = DateTime * int * string
type stockVolume = DateTime * int
type tweetProvider = string -> tweet seq
type stockVolumeProvider = string -> stockVolume seq