<commit_before>class Beeramid

  attr_reader :price, :amount

  def initialize(params={})
    @price = params.fetch(:price, 5.0).to_f
    @amount = params.fetch(:amount, 50.0).to_f
  end

  def buy_beer
    (amount/price).to_i
  end

  def calculate
    if price <= 0
      return nil
    end

    # We should return no levels if we don't have any money or not enough
    # money to buy any beer!
    if amount <= 0 or amount < price
      return 0
    end

    # Calculate how much beer we can buy and initialize the number of levels
    # to zero.
    cans_remaining = buy_beer
    levels = 0

    # Each n level requires n beers, so while we have beers left and they are
    # more than the next level's cost (n + 1) then we can add a level.
    # Otherwise we have reached the maximum number of levels.
    while cans_remaining > 0
      if cans_remaining < levels + 1
        return levels
      else
        levels += 1
        cans_remaining -= levels
      end
    end
  end

end
<commit_msg>We still need to return levels at the end<commit_after>class Beeramid

  attr_reader :price, :amount

  def initialize(params={})
    @price = params.fetch(:price, 5.0).to_f
    @amount = params.fetch(:amount, 50.0).to_f
  end

  def buy_beer
    (amount/price).to_i
  end

  def calculate
    if price <= 0
      return nil
    end

    # We should return no levels if we don't have any money or not enough
    # money to buy any beer!
    if amount <= 0 or amount < price
      return 0
    end

    # Calculate how much beer we can buy and initialize the number of levels
    # to zero.
    cans_remaining = buy_beer
    levels = 0

    # Each n level requires n beers, so while we have beers left and they are
    # more than the next level's cost (n + 1) then we can add a level.
    # Otherwise we have reached the maximum number of levels.
    while cans_remaining > 0
      if cans_remaining < levels + 1
        return levels
      else
        levels += 1
        cans_remaining -= levels
      end
    end

    # If we use all of the cans then the loop breaks, return the number of
    # levels.
    levels
  end

end

{'fraction_non_alphanumeric': 0.06200093940817285, 'fraction_numerical': 0.012212306247064349, 'mean_word_length': 2.227272727272727, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1303443', 'n_tokens_mistral': 684, 'n_tokens_neox': 623, 'n_words': 283}