Created
          June 20, 2016 18:16 
        
      - 
      
 - 
        
Save ctrombley/88244a6245035b5bebf858a724b1bf07 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
ctrombley renamed this gist
Jun 20, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
ctrombley created this gist
Jun 20, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ require 'minitest/autorun' describe "LanguageSolver" do let (:solver) { LanguageSolver.new } it "should generate pairs for comparison" do solver.pairs(['ccda','ccbk', 'cd', 'a', 'ab', 'abd', 'aba']) .must_equal([['d','b'],['c','d'],['c','a'],['d','a']]) end end class LanguageSolver def pairs(ary) pairs = [] ary[1..-1].each_with_index do |word, i| puts (0...word.size).each do |j| puts "comparing #{ary[i-1][j]}, #{word[j]}" if ary[i-1][j] == word[j] || ary.size <= j next end puts "found difference" pairs << [ary[i-1][j], word[j]] break end end pairs end end