Skip to content

Instantly share code, notes, and snippets.

View hoppula's full-sized avatar

Lari Hoppula hoppula

View GitHub Profile
function (input) {
return Math.max.apply(Math, input.split('').map(Number).map(function(num, index, arr) {
return arr.slice(index, index+5).reduce(function(memo, num) {
return memo * num;
}, 1);
}, 0));
}
@hoppula
hoppula / bot.js
Created December 19, 2011 19:48
Simple chatbot using multimethod.js
var multimethod = require('multimethod');
var _ = require('underscore');
// expected message format: {from: String, text: String}
var Bot = function() {
this.regexps = {};
this.dispatcher = multimethod().dispatch(function(message) {
var regexp = _.find(this.regexps, function(regexp, key) {
@hoppula
hoppula / fizzbuzz.rb
Created November 18, 2011 15:24
ruby fizzbuzz
(1..100).each do |i|
s = "#{'Fizz' if (i%3).zero?}#{'Buzz' if (i%5).zero?}"
puts s.empty? ? i : s
end