coffeescript algorithms