<commit_before>module Codebreaker
  class Game
    HINTS = 3
    ATTEMPTS = 10
    CODE_SIZE = 4
    NUM_RANGE = 1..6

    def initialize
      @secret_code = ''
    end

    def start
      @secret_code = code_generator
      puts "Enter #{CODE_SIZE} numbers.".green +
               " Each num should be in range #{NUM_RANGE.to_s}.".green
      guess_num = gets.chomp
      validate_guess_num(guess_num)
      compare_input(guess_num.to_i)
    end

    private

    def code_generator
      code = []
      CODE_SIZE.times { code << rand(NUM_RANGE) }
      code.join.to_i
    end

    def validate_guess_num(num)
      begin
        if num.length != CODE_SIZE || !num.match(/[1-6]+/)
          raise "Should be #{CODE_SIZE} nums, each num between #{NUM_RANGE}".red
        end
      rescue Exception => e
        puts e.message
        start
      end
    end

    def compare_input(num)
      if num == @secret_code
        puts "Congratulations!!! You won the game. ".yellow +
                 "The code was #{num}.".yellow
      else

      end
    end

    def match_postion(num)

    end
  end
end
puts 'Ready for challenge ? (type yes/no)'
start_game = gets.chomp
if start_game == 'yes'
  puts 'Let\'s start!!!'
  game = Codebreaker::Game.new
  game.start
else
  exec('exit')
end<commit_msg>fixed matcher<commit_after>module Codebreaker
  # Logic game
  class Game
    HINTS = 3
    ATTEMPTS = 10
    CODE_SIZE = 4
    NUM_RANGE = 1..6

    def initialize
      @secret_code = code_generator
    end

    def start
      puts "Enter #{CODE_SIZE} numbers.".green +
               " Each num should be in range #{NUM_RANGE}.".green
      guess_num = gets.chomp
      validate_guess_num(guess_num)
      compare_input(guess_num)
    end

    private

    def code_generator
      code = []
      CODE_SIZE.times { code << rand(NUM_RANGE) }
      code.join
    end

    def validate_guess_num(num)
      if num.length != CODE_SIZE || !num.match(/[1-6]+/)
        raise "Should be #{CODE_SIZE} nums, each num between #{NUM_RANGE}".red
      end
    rescue => e
      puts e.message
      start
    end

    def compare_input(num)
      if num == @secret_code
        puts 'Congratulations!!! You won the game. '.yellow +
                 "The code was #{num}.".yellow
      else
        puts 'Try again. ' + match_position(num)
        start
      end
    end

    def match_position(num)
      code = @secret_code.chars
      num = num.chars
      guess = num.map.with_index do |item, index|
        next if item != code[index]
        code[index] = nil
        '+'
      end
      num.each do |item|
        next unless code.include?(item)
        guess << '-'
        code.delete_at(code.index(item))
      end
      guess.join
    end
  end
end
puts 'Ready for challenge ? (type yes/no)'
start_game = gets.chomp
if start_game == 'yes'
  puts 'Let\'s start!!!'
  Codebreaker::Game.new.start
else
  exec('exit')
end
{'fraction_non_alphanumeric': 0.1023972602739726, 'fraction_numerical': 0.005479452054794521, 'mean_word_length': 2.008238928939238, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '776742', 'n_tokens_mistral': 984, 'n_tokens_neox': 961, 'n_words': 255}