<commit_before>class BowlingGame
  def initialize
    @total = 0
    @frames = []
  end

  def roll(score)
    last = @frames.last
    if last && last.size < 2 && last[0] != 10
      last << score
    else
      @frames << [score]
    end
  end

  def score
    total_score = 0
    is_spare = false
    is_strike = false
    @frames.each do |frame|
      frame_score = frame.inject { |sum, n| sum + n }
      if is_strike
        total_score += frame_score * 2
      elsif is_spare 
        total_score += (frame[0] * 2)
        total_score += frame[1] if frame.size > 1
      else
        total_score += frame_score
      end
      is_spare = frame_score == 10
      is_strike = frame[0] == 10
    end
    total_score
  end
end<commit_msg>Refactor - 4 examples now failing<commit_after>class BowlingGame
  def initialize
    @total = 0
    @frames = []
  end

  def roll(score)
    last = @frames.last
    if last && last.size < 2 && last[0] != 10
      last << score
    else
      @frames << [score]
    end
  end

  def score
    total_score = 0
    @frames.each_with_index do |frame, index|
      frame_score = frame.inject { |sum, n| sum + n }
      is_spare = frame_score == 10
      is_strike = frame[0] == 10
      if is_strike
        total_score += frame_score + next_two_scores(index)
      elsif is_spare 
        total_score += frame_score + next_score(index)
      else
        total_score += frame_score
      end
    end
    total_score
  end

  def next_score(index)
    0
  end

  def next_two_scores(index)
    0
  end
end
{'fraction_non_alphanumeric': 0.09208819714656291, 'fraction_numerical': 0.019455252918287938, 'mean_word_length': 2.0374015748031495, 'pattern_counts': {'":': 0, '<': 13, '<?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': '1044782', 'n_tokens_mistral': 554, 'n_tokens_neox': 521, 'n_words': 145}