wordl-solver 1.1.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/VERSION +1 -1
 - data/bin/wordl-solver +2 -2
 - data/lib/wordl_solver.rb +36 -127
 - data/lib/wordl_solver_interface.rb +106 -0
 - data/wordl-solver.gemspec +4 -3
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: fb3bf465211db353a6705e7a34a9678ab1c054e02fc8ee99c6420577705b8a09
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 90e1a0ccec7e76c4c4e9609f8e55a858c557b7db48d73658ec0f3c8acb59f3cf
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7056a94cb5ad3f64cd8bbef26ae67e5bc72a7f85df20ad5084ef49e7a8f882236cb6fd6c97de30ee67f338035b14b5176838a74ac09bc473d8c5de46e33ff23b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: b549d2effd15ae76b8910efaba4912d3f2f2974c335a2b5d5e99f08bcf79433f6256d2da37ce02f3e5ce57019e282d88a0caf185f05eb2ac135ce7831b1931b2
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            1. 
     | 
| 
      
 1 
     | 
    
         
            +
            1.3.0
         
     | 
    
        data/bin/wordl-solver
    CHANGED
    
    
    
        data/lib/wordl_solver.rb
    CHANGED
    
    | 
         @@ -1,9 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require  
     | 
| 
       4 
     | 
    
         
            -
            require  
     | 
| 
      
 3 
     | 
    
         
            +
            require "csv"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "fileutils"
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            FILE_PATH = File.join(File.dirname(__FILE__),  
     | 
| 
      
 6 
     | 
    
         
            +
            FILE_PATH = File.join(File.dirname(__FILE__), "5_words.csv")
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            LETTER_WORDS = []
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
         @@ -11,138 +11,47 @@ CSV.foreach(FILE_PATH) do |row| 
     | 
|
| 
       11 
11 
     | 
    
         
             
              LETTER_WORDS << row[0]
         
     | 
| 
       12 
12 
     | 
    
         
             
            end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
      
 14 
     | 
    
         
            +
            # The Class WordlSolver is a class that contains the methods to solve the wordl puzzle.
         
     | 
| 
       14 
15 
     | 
    
         
             
            class WordlSolver
         
     | 
| 
       15 
     | 
    
         
            -
               
     | 
| 
       16 
     | 
    
         
            -
                 
     | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
       18 
     | 
    
         
            -
                   
     | 
| 
       19 
     | 
    
         
            -
                   
     | 
| 
       20 
     | 
    
         
            -
                   
     | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                   
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
              def self.run
         
     | 
| 
       35 
     | 
    
         
            -
                WordlSolver.new.run
         
     | 
| 
       36 
     | 
    
         
            -
              end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
              def run
         
     | 
| 
       39 
     | 
    
         
            -
                answer = ''
         
     | 
| 
       40 
     | 
    
         
            -
                while answer != 'y'
         
     | 
| 
       41 
     | 
    
         
            -
                  ask_for_letters_and_colours
         
     | 
| 
       42 
     | 
    
         
            -
                  find_possible_words
         
     | 
| 
       43 
     | 
    
         
            -
                  present_possible_words
         
     | 
| 
       44 
     | 
    
         
            -
                  puts 'have you found it ? (y/n)'
         
     | 
| 
       45 
     | 
    
         
            -
                  answer = gets.chomp
         
     | 
| 
       46 
     | 
    
         
            -
                end
         
     | 
| 
       47 
     | 
    
         
            -
              end
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
              private
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
              def ask_for_letters_and_colours
         
     | 
| 
       52 
     | 
    
         
            -
                puts 'Type in order color initial then the letter'
         
     | 
| 
       53 
     | 
    
         
            -
                puts '(s for silver, y for yellow and g for green)'
         
     | 
| 
       54 
     | 
    
         
            -
                5.times do |t|
         
     | 
| 
       55 
     | 
    
         
            -
                  puts @greens[t]
         
     | 
| 
       56 
     | 
    
         
            -
                  if @greens[t].nil?
         
     | 
| 
       57 
     | 
    
         
            -
                    puts "for position #{t + 1}"
         
     | 
| 
       58 
     | 
    
         
            -
                    letters = gets.chomp
         
     | 
| 
       59 
     | 
    
         
            -
                    while check_word_correct(letters)
         
     | 
| 
       60 
     | 
    
         
            -
                      puts "sorry, didn't catch that, try again:"
         
     | 
| 
       61 
     | 
    
         
            -
                      letters = gets.chomp
         
     | 
| 
      
 16 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 17 
     | 
    
         
            +
                def find_possible_words(greys, greens, yellows)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @greys = greys
         
     | 
| 
      
 19 
     | 
    
         
            +
                  @greens = greens 
         
     | 
| 
      
 20 
     | 
    
         
            +
                  @yellows = yellows
         
     | 
| 
      
 21 
     | 
    
         
            +
                  @possible_words = @possible_words.nil? || @possible_words.empty? ? LETTER_WORDS : @possible_words
         
     | 
| 
      
 22 
     | 
    
         
            +
                  filter_greens
         
     | 
| 
      
 23 
     | 
    
         
            +
                  filter_yellows
         
     | 
| 
      
 24 
     | 
    
         
            +
                  filter_greys
         
     | 
| 
      
 25 
     | 
    
         
            +
                  @possible_words
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                def filter_greens
         
     | 
| 
      
 29 
     | 
    
         
            +
                  @possible_words.select! do |word|
         
     | 
| 
      
 30 
     | 
    
         
            +
                    put_in = true
         
     | 
| 
      
 31 
     | 
    
         
            +
                    @greens.each do |key, value|
         
     | 
| 
      
 32 
     | 
    
         
            +
                      next if value.nil?
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                      put_in = false unless word[key] == value
         
     | 
| 
       62 
35 
     | 
    
         
             
                    end
         
     | 
| 
       63 
     | 
    
         
            -
                     
     | 
| 
       64 
     | 
    
         
            -
                  else
         
     | 
| 
       65 
     | 
    
         
            -
                    puts "for position #{t + 1} this #{@greens[t]}"
         
     | 
| 
      
 36 
     | 
    
         
            +
                    put_in
         
     | 
| 
       66 
37 
     | 
    
         
             
                  end
         
     | 
| 
       67 
38 
     | 
    
         
             
                end
         
     | 
| 
       68 
     | 
    
         
            -
              end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
              def sort_letter_upon_color(letters, t)
         
     | 
| 
       71 
     | 
    
         
            -
                case letters[0]
         
     | 
| 
       72 
     | 
    
         
            -
                when 's'
         
     | 
| 
       73 
     | 
    
         
            -
                  @greys << letters[1]
         
     | 
| 
       74 
     | 
    
         
            -
                when 'y'
         
     | 
| 
       75 
     | 
    
         
            -
                  @yellows[t] << letters[1]
         
     | 
| 
       76 
     | 
    
         
            -
                else
         
     | 
| 
       77 
     | 
    
         
            -
                  @greens[t] = letters[1]
         
     | 
| 
       78 
     | 
    
         
            -
                end
         
     | 
| 
       79 
     | 
    
         
            -
                @greys.reject! { |letter| @greens.include?(letter) || @yellows.values.flatten.include?(letter) }
         
     | 
| 
       80 
     | 
    
         
            -
              end
         
     | 
| 
       81 
39 
     | 
    
         | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                hash_word_frequency = {}
         
     | 
| 
       92 
     | 
    
         
            -
                set_letters_frequencies
         
     | 
| 
       93 
     | 
    
         
            -
                @possible_words.each do |word|
         
     | 
| 
       94 
     | 
    
         
            -
                  count = 0
         
     | 
| 
       95 
     | 
    
         
            -
                  word.chars.uniq.each do |char|
         
     | 
| 
       96 
     | 
    
         
            -
                    count += @frenquencies[char]
         
     | 
| 
       97 
     | 
    
         
            -
                  end
         
     | 
| 
       98 
     | 
    
         
            -
                  hash_word_frequency[word] = count
         
     | 
| 
       99 
     | 
    
         
            -
                end
         
     | 
| 
       100 
     | 
    
         
            -
                hash_word_frequency = hash_word_frequency.sort_by { |_k, v| v }
         
     | 
| 
       101 
     | 
    
         
            -
                hash_word_frequency.each do |word, count|
         
     | 
| 
       102 
     | 
    
         
            -
                  p "#{word} : #{count}"
         
     | 
| 
       103 
     | 
    
         
            -
                end
         
     | 
| 
       104 
     | 
    
         
            -
              end
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
              def filter_greens
         
     | 
| 
       107 
     | 
    
         
            -
                @possible_words.select! do |word|
         
     | 
| 
       108 
     | 
    
         
            -
                  put_in = true
         
     | 
| 
       109 
     | 
    
         
            -
                  @greens.each do |key, value|
         
     | 
| 
       110 
     | 
    
         
            -
                    next if value.nil?
         
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
                    put_in = false unless word[key] == value
         
     | 
| 
       113 
     | 
    
         
            -
                  end
         
     | 
| 
       114 
     | 
    
         
            -
                  put_in
         
     | 
| 
       115 
     | 
    
         
            -
                end
         
     | 
| 
       116 
     | 
    
         
            -
              end
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
              def filter_yellows
         
     | 
| 
       119 
     | 
    
         
            -
                yellow_letters = @yellows.values.flatten.uniq
         
     | 
| 
       120 
     | 
    
         
            -
                @possible_words.select! do |word|
         
     | 
| 
       121 
     | 
    
         
            -
                  possible = true
         
     | 
| 
       122 
     | 
    
         
            -
                  word.chars.each_with_index do |letter, index|
         
     | 
| 
       123 
     | 
    
         
            -
                    possible = false if @yellows[index].include?(letter)
         
     | 
| 
      
 40 
     | 
    
         
            +
                def filter_yellows
         
     | 
| 
      
 41 
     | 
    
         
            +
                  yellow_letters = @yellows.values.flatten.uniq
         
     | 
| 
      
 42 
     | 
    
         
            +
                  @possible_words.select! do |word|
         
     | 
| 
      
 43 
     | 
    
         
            +
                    possible = true
         
     | 
| 
      
 44 
     | 
    
         
            +
                    word.chars.each_with_index do |letter, index|
         
     | 
| 
      
 45 
     | 
    
         
            +
                      possible = false if @yellows[index].include?(letter)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end
         
     | 
| 
      
 47 
     | 
    
         
            +
                    possible = false unless yellow_letters.all? { |letter| word.include?(letter) }
         
     | 
| 
      
 48 
     | 
    
         
            +
                    possible
         
     | 
| 
       124 
49 
     | 
    
         
             
                  end
         
     | 
| 
       125 
     | 
    
         
            -
                  possible = false unless yellow_letters.all? { |letter| word.include?(letter) }
         
     | 
| 
       126 
     | 
    
         
            -
                  possible
         
     | 
| 
       127 
     | 
    
         
            -
                end
         
     | 
| 
       128 
     | 
    
         
            -
              end
         
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
              def filter_greys
         
     | 
| 
       131 
     | 
    
         
            -
                @possible_words.reject! do |word|
         
     | 
| 
       132 
     | 
    
         
            -
                  @greys.any? { |letter| word.include?(letter) }
         
     | 
| 
       133 
50 
     | 
    
         
             
                end
         
     | 
| 
       134 
     | 
    
         
            -
              end
         
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
              def check_word_correct(letters)
         
     | 
| 
       137 
     | 
    
         
            -
                letters.length != 2 || !%w[s y g].include?(letters[0])
         
     | 
| 
       138 
     | 
    
         
            -
              end
         
     | 
| 
       139 
51 
     | 
    
         | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
                  word.chars.each do |letter|
         
     | 
| 
       144 
     | 
    
         
            -
                    @frenquencies[letter] = 0 if @frenquencies[letter].nil?
         
     | 
| 
       145 
     | 
    
         
            -
                    @frenquencies[letter] += 1
         
     | 
| 
      
 52 
     | 
    
         
            +
                def filter_greys
         
     | 
| 
      
 53 
     | 
    
         
            +
                  @possible_words.reject! do |word|
         
     | 
| 
      
 54 
     | 
    
         
            +
                    @greys.any? { |letter| word.include?(letter) }
         
     | 
| 
       146 
55 
     | 
    
         
             
                  end
         
     | 
| 
       147 
56 
     | 
    
         
             
                end
         
     | 
| 
       148 
57 
     | 
    
         
             
              end
         
     | 
| 
         @@ -0,0 +1,106 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require_relative "wordl_solver"
         
     | 
| 
      
 2 
     | 
    
         
            +
            class WordlSolverInterface
         
     | 
| 
      
 3 
     | 
    
         
            +
              def self.run
         
     | 
| 
      
 4 
     | 
    
         
            +
                new.run
         
     | 
| 
      
 5 
     | 
    
         
            +
              end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 8 
     | 
    
         
            +
                @yellows = {
         
     | 
| 
      
 9 
     | 
    
         
            +
                  0 => [],
         
     | 
| 
      
 10 
     | 
    
         
            +
                  1 => [],
         
     | 
| 
      
 11 
     | 
    
         
            +
                  2 => [],
         
     | 
| 
      
 12 
     | 
    
         
            +
                  3 => [],
         
     | 
| 
      
 13 
     | 
    
         
            +
                  4 => []
         
     | 
| 
      
 14 
     | 
    
         
            +
                }
         
     | 
| 
      
 15 
     | 
    
         
            +
                @greys = []
         
     | 
| 
      
 16 
     | 
    
         
            +
                @greens = {
         
     | 
| 
      
 17 
     | 
    
         
            +
                  0 => nil,
         
     | 
| 
      
 18 
     | 
    
         
            +
                  1 => nil,
         
     | 
| 
      
 19 
     | 
    
         
            +
                  2 => nil,
         
     | 
| 
      
 20 
     | 
    
         
            +
                  3 => nil,
         
     | 
| 
      
 21 
     | 
    
         
            +
                  4 => nil
         
     | 
| 
      
 22 
     | 
    
         
            +
                }
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              def run
         
     | 
| 
      
 26 
     | 
    
         
            +
                answer = ""
         
     | 
| 
      
 27 
     | 
    
         
            +
                while answer != "y"
         
     | 
| 
      
 28 
     | 
    
         
            +
                  ask_for_letters_and_colours
         
     | 
| 
      
 29 
     | 
    
         
            +
                  @possible_words = WordlSolver.find_possible_words(@greys, @greens, @yellows)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  present_possible_words
         
     | 
| 
      
 31 
     | 
    
         
            +
                  puts "have you found it ? (y/n)"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  answer = gets.chomp
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              private
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              def sort_letter_upon_color(letters, t)
         
     | 
| 
      
 39 
     | 
    
         
            +
                case letters[0]
         
     | 
| 
      
 40 
     | 
    
         
            +
                when "s"
         
     | 
| 
      
 41 
     | 
    
         
            +
                  @greys << letters[1]
         
     | 
| 
      
 42 
     | 
    
         
            +
                when "y"
         
     | 
| 
      
 43 
     | 
    
         
            +
                  @yellows[t] << letters[1]
         
     | 
| 
      
 44 
     | 
    
         
            +
                else
         
     | 
| 
      
 45 
     | 
    
         
            +
                  @greens[t] = letters[1]
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
                @greys.reject! { |letter| @greens.include?(letter) || @yellows.values.flatten.include?(letter) }
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              def ask_for_letters_and_colours
         
     | 
| 
      
 51 
     | 
    
         
            +
                puts "Type two letters attached. First the initial of the color you have"
         
     | 
| 
      
 52 
     | 
    
         
            +
                puts "(s for silver (grey), y for yellow and g for green)"
         
     | 
| 
      
 53 
     | 
    
         
            +
                puts "and then the letter that was tried."
         
     | 
| 
      
 54 
     | 
    
         
            +
                puts "For example, if you have tried and arose and you get grey for a"
         
     | 
| 
      
 55 
     | 
    
         
            +
                puts "You'd type, after being prompted for the first position: sa "
         
     | 
| 
      
 56 
     | 
    
         
            +
                5.times do |position|
         
     | 
| 
      
 57 
     | 
    
         
            +
                  puts @greens[position]
         
     | 
| 
      
 58 
     | 
    
         
            +
                  if @greens[position].nil?
         
     | 
| 
      
 59 
     | 
    
         
            +
                    puts "for position #{position + 1}"
         
     | 
| 
      
 60 
     | 
    
         
            +
                    letters = retrieve_input_letters
         
     | 
| 
      
 61 
     | 
    
         
            +
                    sort_letter_upon_color(letters, position)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  else
         
     | 
| 
      
 63 
     | 
    
         
            +
                    puts "for position #{position + 1} this #{@greens[position]}"
         
     | 
| 
      
 64 
     | 
    
         
            +
                  end
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              def present_possible_words
         
     | 
| 
      
 69 
     | 
    
         
            +
                puts "here are the existing words"
         
     | 
| 
      
 70 
     | 
    
         
            +
                hash_word_frequency = {}
         
     | 
| 
      
 71 
     | 
    
         
            +
                set_letters_frequencies
         
     | 
| 
      
 72 
     | 
    
         
            +
                @possible_words.each do |word|
         
     | 
| 
      
 73 
     | 
    
         
            +
                  count = 0
         
     | 
| 
      
 74 
     | 
    
         
            +
                  word.chars.uniq.each do |char|
         
     | 
| 
      
 75 
     | 
    
         
            +
                    count += @frenquencies[char]
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
      
 77 
     | 
    
         
            +
                  hash_word_frequency[word] = count
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
                hash_word_frequency = hash_word_frequency.sort_by { |_k, v| v }
         
     | 
| 
      
 80 
     | 
    
         
            +
                hash_word_frequency.each do |word, count|
         
     | 
| 
      
 81 
     | 
    
         
            +
                  p "#{word} : #{count}"
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              def word_is_correct?(letters)
         
     | 
| 
      
 86 
     | 
    
         
            +
                letters.length == 2 && %w[s y g].include?(letters[0])
         
     | 
| 
      
 87 
     | 
    
         
            +
              end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
              def set_letters_frequencies
         
     | 
| 
      
 90 
     | 
    
         
            +
                @frenquencies = Hash.new(0)
         
     | 
| 
      
 91 
     | 
    
         
            +
                @possible_words.each do |word|
         
     | 
| 
      
 92 
     | 
    
         
            +
                  word.chars.each do |letter|
         
     | 
| 
      
 93 
     | 
    
         
            +
                    @frenquencies[letter] += 1
         
     | 
| 
      
 94 
     | 
    
         
            +
                  end
         
     | 
| 
      
 95 
     | 
    
         
            +
                end
         
     | 
| 
      
 96 
     | 
    
         
            +
              end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              def retrieve_input_letters
         
     | 
| 
      
 99 
     | 
    
         
            +
                letters = gets.chomp
         
     | 
| 
      
 100 
     | 
    
         
            +
                until word_is_correct?(letters)
         
     | 
| 
      
 101 
     | 
    
         
            +
                  puts "sorry, didn't catch that, try again:"
         
     | 
| 
      
 102 
     | 
    
         
            +
                  letters = gets.chomp
         
     | 
| 
      
 103 
     | 
    
         
            +
                end
         
     | 
| 
      
 104 
     | 
    
         
            +
                letters
         
     | 
| 
      
 105 
     | 
    
         
            +
              end
         
     | 
| 
      
 106 
     | 
    
         
            +
            end
         
     | 
    
        data/wordl-solver.gemspec
    CHANGED
    
    | 
         @@ -2,16 +2,16 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            # DO NOT EDIT THIS FILE DIRECTLY
         
     | 
| 
       3 
3 
     | 
    
         
             
            # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
         
     | 
| 
       4 
4 
     | 
    
         
             
            # -*- encoding: utf-8 -*-
         
     | 
| 
       5 
     | 
    
         
            -
            # stub: wordl-solver 1. 
     | 
| 
      
 5 
     | 
    
         
            +
            # stub: wordl-solver 1.3.0 ruby lib
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       8 
8 
     | 
    
         
             
              s.name = "wordl-solver".freeze
         
     | 
| 
       9 
     | 
    
         
            -
              s.version = "1. 
     | 
| 
      
 9 
     | 
    
         
            +
              s.version = "1.3.0"
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
         
     | 
| 
       12 
12 
     | 
    
         
             
              s.require_paths = ["lib".freeze]
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.authors = ["george kosmopoulos".freeze]
         
     | 
| 
       14 
     | 
    
         
            -
              s.date = "2022- 
     | 
| 
      
 14 
     | 
    
         
            +
              s.date = "2022-06-16"
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.description = "This gem helps you solve wordl puzzles. It does so by asking you for the letters position you know, the letters you know exists and the ones you know don't exists. It then proposes words depending on how good they are by weighting the letters by their frequency in the english language.".freeze
         
     | 
| 
       16 
16 
     | 
    
         
             
              s.email = "gkosmo1@hotmail.com".freeze
         
     | 
| 
       17 
17 
     | 
    
         
             
              s.executables = ["wordl-solver".freeze]
         
     | 
| 
         @@ -30,6 +30,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       30 
30 
     | 
    
         
             
                "bin/wordl-solver",
         
     | 
| 
       31 
31 
     | 
    
         
             
                "lib/5_words.csv",
         
     | 
| 
       32 
32 
     | 
    
         
             
                "lib/wordl_solver.rb",
         
     | 
| 
      
 33 
     | 
    
         
            +
                "lib/wordl_solver_interface.rb",
         
     | 
| 
       33 
34 
     | 
    
         
             
                "wordl-solver.gemspec"
         
     | 
| 
       34 
35 
     | 
    
         
             
              ]
         
     | 
| 
       35 
36 
     | 
    
         
             
              s.homepage = "http://github.com/gkosmo/wordl-solver".freeze
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: wordl-solver
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.3.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - george kosmopoulos
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-06-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: shoulda
         
     | 
| 
         @@ -102,6 +102,7 @@ files: 
     | 
|
| 
       102 
102 
     | 
    
         
             
            - bin/wordl-solver
         
     | 
| 
       103 
103 
     | 
    
         
             
            - lib/5_words.csv
         
     | 
| 
       104 
104 
     | 
    
         
             
            - lib/wordl_solver.rb
         
     | 
| 
      
 105 
     | 
    
         
            +
            - lib/wordl_solver_interface.rb
         
     | 
| 
       105 
106 
     | 
    
         
             
            - wordl-solver.gemspec
         
     | 
| 
       106 
107 
     | 
    
         
             
            homepage: http://github.com/gkosmo/wordl-solver
         
     | 
| 
       107 
108 
     | 
    
         
             
            licenses:
         
     |