Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-crandall committed Apr 29, 2022
1 parent 6ca702c commit 4ace53c
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions wordle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def finding_unique_letters?
end

def word_list
return @possible_answers if @possible_answers.length <= guess_when_words_remain

finding_unique_letters? ? @guess_word_list : @possible_answers
end

Expand Down Expand Up @@ -266,25 +268,7 @@ def rate_words

@possibilities = {}

# Return early because there's random chance at this point
if @possible_answers.length <= guess_when_words_remain
@possible_answers.each do |word|
@possibilities[word] = rate_word(word)
end
return
end

@needed_letters = needed_letters
guess_words = word_list

# All letters are found. Just try out remaining words.
if @needed_letters.empty?
puts 'Needed letters is empty. Trying out remaining words.' if debug?
guess_words.each do |word|
@possibilities[word] = rate_word(word)
end
return
end

# Try to rule out remaining letters
word_list.each do |word|
Expand Down Expand Up @@ -336,9 +320,7 @@ def create_distribution

@distribution = @positional_ratings ? empty_positional_distribution : empty_distribution

word_list = @possible_answers

word_list.each do |word|
@possible_answers.each do |word|
next if limit_distribution_to_eligible_words && word_matcher.word_disqualified?(word)

distribution_by_letter(word)
Expand Down

0 comments on commit 4ace53c

Please sign in to comment.