Some algorithms in CoffeeScript