Skip to content

Instantly share code, notes, and snippets.

View presidentbeef's full-sized avatar
🐢
May be slow to respond on OSS projects

Justin Collins presidentbeef

🐢
May be slow to respond on OSS projects
View GitHub Profile
def dameraulevenshtein(seq1, seq2)
len1 = seq1.length
len2 = seq2.length
oneago = nil
row = (1..len2).to_a << 0
len1.times do |i|
twoago, oneago, row = oneago, row, Array.new(len2) {0} << (i + 1)
len2.times do |j|
cost = seq1[i] == seq2[j] ? 0 : 1
delcost = oneago[j] + 1
#A little Twitter thing to post random quotes from Edsger Dijkstra
require 'yaml'
require 'open-uri'
require 'twitter' #twitter4r gem
require 'hpricot'
class DijkstraQuote
class << self