lib/mastermind/game.rb
# When the codebreaker submits a guess, grade it against the mastermind's code.
When the codebreaker submits a guess, grade it against the mastermind's code.
When the codebreaker submits a guess grade it against the mastermind ' s code .
def guess(guess)
      result = [nil,nil,nil,nil]
      guess.each_with_index do |peg, index|
        if @code[index] == peg
          result[index] = "b"
        elsif @code.include?(peg)
          result[@code.index(peg)] ||= "w"
        end
      end
      @messenger.puts result.compact.sort.join
    end
def guess ( guess ) result = [ nil , nil , nil , nil ] guess . each_with_index do | peg , index | if @code [ index ] == peg result [ index ] = "b" elsif @code . include? ( peg ) result [ @code . index ( peg ) ] ||= "w" end end @messenger . puts result . compact . sort . join end
When the codebreaker submits a guess, grade it against the mastermind's code.
When the codebreaker submits a guess grade it against the mastermind ' s code .
guess
<not_specific>