Sha256: 6d84b33205089cbf015544e5e8f44aeda6951f9d55c3582ccb2739e69691359e
Contents?: true
Size: 687 Bytes
Versions: 3
Compression:
Stored size: 687 Bytes
Contents
# frozen_string_literal: true require_relative "../string" module Wordle class GuessAnalyzer def initialize(target_word, guess) @target_word = target_word @guess = guess end def match? @guess.downcase.strip == @target_word end def colors target_letters = @target_word.chars guess_letters = @guess.chars colored_letters = "" guess_letters.each_with_index do |letter, i| colored_letters += if letter == target_letters[i] letter.green elsif target_letters.include?(letter) letter.yellow else letter.gray end end colored_letters end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wordle-0.3.0 | lib/wordle/guess_analyzer.rb |
wordle-0.2.1 | lib/wordle/guess_analyzer.rb |
wordle-0.2.0 | lib/wordle/guess_analyzer.rb |