Skip to content

Commit

Permalink
Count dupes by position setting
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-crandall committed Apr 19, 2022
1 parent c163663 commit dd279cf
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions wordle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def count_dupes_by_position

# When looking at word list possibilities, exclude words that are ineligible
def limit_distribution_to_eligible_words
true
false
end

def quiet?
Expand Down Expand Up @@ -162,9 +162,7 @@ def rate_words
@possibilities = {}

word_list = @possible_answers
if guesses < full_guess_list_until
word_list = @possible_answers + @guess_word_list
end
word_list = @possible_answers + @guess_word_list if guesses < full_guess_list_until

word_list.each do |word|
rating = 0
Expand Down Expand Up @@ -196,10 +194,8 @@ def rate_words
def create_distribution
positional_distribution = empty_positional_distribution

regex_pattern = create_regex_pattern

@possible_answers.each do |word|
next unless word.match?(regex_pattern)
next if limit_distribution_to_eligible_words && !eligible?(word)

char_occurance = {}
word_to_hash(word).each do |index, letter|
Expand Down Expand Up @@ -293,12 +289,10 @@ def parse_guess(guess_str)
letter = guess[i]
answer_count = answer.count(letter)
found_count = green_letters.count(letter) + yellow_letters.count(letter)
if answer_count > found_count
if response[i] != 'y'
if answer_count > found_count && (response[i] != 'y')
response[i] = 'm'
yellow_letters.push(letter)
end
end
end
response.join('')
end
Expand Down

0 comments on commit dd279cf

Please sign in to comment.