Skip to content

Instantly share code, notes, and snippets.

@pepijn
Created December 13, 2012 19:30
Show Gist options
  • Save pepijn/4279053 to your computer and use it in GitHub Desktop.
Save pepijn/4279053 to your computer and use it in GitHub Desktop.
words = {
good: "france",
bad: "french"
}
pairs = {
good: [],
bad: []
}
words.each do |kind, word|
buffer = ""
word.each_char do |char|
pairs[kind] << buffer + char
buffer = char
end
end
remainder = (pairs[:good] - pairs[:bad])
result = (remainder.length * 2.0) / (pairs[:good].length + pairs[:bad].length)
#=> 0.5
puts result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment