Created
April 3, 2009 04:57
-
-
Save clayton/89638 to your computer and use it in GitHub Desktop.
This file contains 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
class Compare | |
def self.similar_between?(keeper, finder) | |
finder_scan = finder.scan(/./) | |
keeper_scan = keeper.scan(/./) | |
same = [] | |
keeper_scan.each_with_index{ |char, key| same << char if finder_scan[key] == char } | |
same.join | |
end | |
end | |
puts Compare.similar_between?("salamaner", "salt") # => sal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment