Created
December 13, 2012 19:30
-
-
Save pepijn/4279053 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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