<commit_before>class Math24
  attr_accessor :numbers
  attr_reader :operators
  attr_accessor :target

  def initialize(operators)
    @operators = operators
    @target = 24
  end

  def solve(numbers = [])
    if numbers.empty?
      return "Please provide numbers" if @numbers.empty?
    else
      @numbers = numbers
    end

    @numbers.each do |number|
      if number.to_i < 1 || number.to_i > 9
        return "Please only enter integers between 1 and 9"
      end
    end
    
    op_permutation = @operators.repeated_permutation(3)
    num_permutation = @numbers.permutation(4).to_a.uniq
    current_result = 0

    num_permutation.each do |numbers|
      op_permutation.each do |operators|
        current_result = numbers[0].to_f
        operators.each_with_index do |operator, index|
          current_result = current_result.send(operator.to_sym, numbers[index+1].to_f)
        end
        if current_result == @target
          if (operators.include?("+") || operators.include?("-")) && (operators.include?("*") || operators.include?("/"))
            #Might need parentheses
            return "((#{numbers[0]} #{operators[0]} #{numbers[1]}) #{operators[1]} #{numbers[2]}) #{operators[2]} #{numbers[3]} = 24"
          else
            return "#{numbers[0]} #{operators[0]} #{numbers[1]} #{operators[1]} #{numbers[2]} #{operators[2]} #{numbers[3]} = 24"
          end
          break
        end
      end
    end
    return "No solution found"
  end
end





<commit_msg>Prevents operations from every generating a non-integer.<commit_after>class Math24
  attr_accessor :numbers
  attr_reader :operators
  attr_accessor :target

  def initialize(operators)
    @operators = operators
    @target = 24
  end

  def solve(numbers = [])
    if numbers.empty?
      return "Please provide numbers" if @numbers.empty?
    else
      @numbers = numbers
    end

    @numbers.each do |number|
      if number.to_i < 1 || number.to_i > 9
        return "Please only enter integers between 1 and 9"
      end
    end
    
    op_permutation = @operators.repeated_permutation(3)
    num_permutation = @numbers.permutation(4).to_a.uniq
    current_result = 0

    num_permutation.each do |numbers|
      op_permutation.each do |operators|
        current_result = numbers[0].to_f
        operators.each_with_index do |operator, index|
          current_result = current_result.send(operator.to_sym, numbers[index+1].to_f)
          break if current_result < 1 #Don't allow fractional numbers at any stage
        end
        if current_result == @target
          if (operators.include?("+") || operators.include?("-")) && (operators.include?("*") || operators.include?("/"))
            #Might need parentheses for order of operations
            return "((#{numbers[0]} #{operators[0]} #{numbers[1]}) #{operators[1]} #{numbers[2]}) #{operators[2]} #{numbers[3]} = 24"
          else
            return "#{numbers[0]} #{operators[0]} #{numbers[1]} #{operators[1]} #{numbers[2]} #{operators[2]} #{numbers[3]} = 24"
          end
          break
        end
      end
    end
    return "No solution found"
  end
end






{'fraction_non_alphanumeric': 0.12883631713554988, 'fraction_numerical': 0.02014066496163683, 'mean_word_length': 2.7294398092967818, 'pattern_counts': {'":': 0, '<': 6, '<?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': '5228854', 'n_tokens_mistral': 1041, 'n_tokens_neox': 967, 'n_words': 243}