<commit_before>class Mastermind
  attr_reader :puzzle
  attr_reader :colors, :pegs, :guesses

  def initialize(args = {})
    @colors = args[:colors] || 6
    @pegs = args[:pegs] || 4
    @guesses = args[:guesses] || 10
    @puzzle = args[:puzzle] || Array.new(self.pegs) { rand(self.colors) + 1 }

    @guesses_made = 0
    @last = []
  end

  def guess!(p)
    if self.solved? then
      raise "This puzzle has already been solved. You can stop guessing now!"
    end
    if @guesses_made == @guesses then
      raise "You haven't solved this puzzle. Better luck next time!"
    end
    self.validate p
    @last = p
    @solved = p == self.puzzle
    @guesses_made += 1
  end

  def validate(p)
    p.size == self.pegs or raise "Solutions should be of size #{self.pegs}; received solution of size #{p.size}"
    p.each do |i|
      i.between? 1, self.colors or raise "#{i} is out of bounds; should be in [1,#{self.colors}]"
    end
  end

  def solved?
    @solved
  end

  def pegs_correct
    return puzzle.zip(@last).inject(0) do |acc,i|
      acc = acc + 1 if i.reduce(:==)
      acc
    end
  end

  def colors_correct
    0
  end
end<commit_msg>working for colors correct<commit_after>class Mastermind
  attr_reader :puzzle
  attr_reader :colors, :pegs, :guesses

  def initialize(args = {})
    @colors = args[:colors] || 6
    @pegs = args[:pegs] || 4
    @guesses = args[:guesses] || 10
    @puzzle = args[:puzzle] || Array.new(self.pegs) { rand(self.colors) + 1 }

    @guesses_made = 0
    @last = []
  end

  def guess!(p)
    if self.solved? then
      raise "This puzzle has already been solved. You can stop guessing now!"
    end
    if @guesses_made == @guesses then
      raise "You haven't solved this puzzle. Better luck next time!"
    end
    self.validate p
    @last = p
    @solved = p == self.puzzle
    @guesses_made += 1
  end

  def validate(p)
    p.size == self.pegs or raise "Solutions should be of size #{self.pegs}; received solution of size #{p.size}"
    p.each do |i|
      i.between? 1, self.colors or raise "#{i} is out of bounds; should be in [1,#{self.colors}]"
    end
  end

  def solved?
    @solved
  end

  def pegs_correct
    return puzzle.zip(@last).inject(0) do |acc,i|
      acc = acc + 1 if i.reduce(:==)
      acc
    end
  end

  def colors_correct
    t1 = Array.new(colors,0)
    t2 = Array.new(colors,0)
    puzzle.each {|i| t1[i-1] += 1 }
    @last.each {|i| t2[i-1] += 1 }
    a = t1.zip(t2).inject(0) do |acc,x|
      acc = acc + 1 if x.all? {|z| z > 0}
      acc
    end
  end
end
{'fraction_non_alphanumeric': 0.13286163522012578, 'fraction_numerical': 0.014937106918238994, 'mean_word_length': 2.5249307479224377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1819461', 'n_tokens_mistral': 972, 'n_tokens_neox': 912, 'n_words': 287}