<commit_before># Your Names
# 1)<NAME>
# 2)

# We spent [1] hours on this challenge.

# Bakery Serving Size portion calculator.

#Input: Hash of baked goods, that accepts two arguments
#Output: String of calculations for baked goods that counts serving sizes, returns leftover ingredients, and raises error when invalid input is entered

#Create hash that accepts a key of type of baked good, and a value of number of ingredients
#Set an error counter to 3, where an ArgumentError is raised if an invalid key input is entered,
#Otherwise iterate over hash to determine how many ingredients are needed, and  calculate remaining ingredients to suggest a baked good.

#Features to add
#Suggested baking items

#Create a class?

def serving_size_calc(item_to_make, num_of_ingredients)
  library = {"cookie" => 1, "cake" =>  5, "pie" => 7}
  suggested_good = ""


    if library.include?(item_to_make) == true
      return library
    else
      raise ArgumentError.new("#{item_to_make} is not a valid input")
    end

  serving_size = library[item_to_make]
  remaining_ingredients = num_of_ingredients % serving_size
  qty_to_make = num_of_ingredients / serving_size

  if remaining_ingredients == 0
    return "Calculations complete: Make #{qty_to_make} of #{item_to_make}"
  else
    library.each do |item, number| if remaining_ingredients >= number
      suggested_good = number
  end
end
  return "Calculations complete: Make #{qty_to_make} of #{item_to_make}, you have #{remaining_ingredients} leftover ingredients. Suggested baking items: #{suggested_good}"
  end

p serving_size_calc("pie", 7)
p serving_size_calc("pie", 8)
p serving_size_calc("cake", 5)
p serving_size_calc("cake", 7)
p serving_size_calc("cookie", 1)
p serving_size_calc("cookie", 10)
p serving_size_calc("THIS IS AN ERROR", 5)

#  Reflection

# What did you learn about making code readable by working on this challenge?
# Since I was solo for this challenge (had to makeup gps), I ended up doing pseudocode based on the code that was already written. That was something I hadn't done before, and it was helpful to break into steps in this way.

# Did you learn any new methods? What did you learn about them?
# I ended up using .include? since it fit well.

# What did you learn about accessing data in hashes?
# You can choose to access a key or value when calling a hash.

# What concepts were solidified when working through this challenge?
# Practicing "reverse" pseudocode was helpful for me!<commit_msg>Add changes from GPS 2.3 makeup review.<commit_after># Your Names
# 1)<NAME>
# 2)N/A

# We spent [1] hours on this challenge.

# Bakery Serving Size portion calculator.

#Input: Hash of baked goods, that accepts two arguments
#Output: String of calculations for baked goods that counts serving sizes, returns leftover ingredients, and raises error when invalid input is entered

#Create hash that accepts a key of the type of baked good, and a value of the number of ingredients
#Set an error counter to 3, where an ArgumentError is raised if an invalid key input is entered,
#Otherwise iterate over hash to determine how many ingredients are needed, and  calculate remaining ingredients to suggest a baked good.

#Features to add
#Suggested baking items
# https://github.com/Devbootcamp/phase-0-code/blob/master/week-6/gps2_3.rb
def serving_size_calc(item_to_make, num_of_ingredients)
  library = {"cookie" => 1, "cake" =>  5, "pie" => 7}
  suggested_good = ""


    # if library.include?(item_to_make) == false
    # https://signalvnoise.com/posts/2699-making-sense-with-rubys-unless
    #if !library.include?(item_to_make) #== false

  # if !not true
  #   do this
  # end

    unless library.include?(item_to_make) #== false
    #   return library
    # else
      raise ArgumentError.new("#{item_to_make} is not a valid input")
    end

  serving_size = library[item_to_make]
  remaining_ingredients = num_of_ingredients % serving_size
  qty_to_make = num_of_ingredients / serving_size

  if remaining_ingredients == 0
    return "Calculations complete: Make #{qty_to_make} of #{item_to_make}"
  else
    library.each do |item, number|
      if remaining_ingredients >= number
        suggested_good = number
      end
    end

  end
  return "Calculations complete: Make #{qty_to_make} of #{item_to_make}, you have #{remaining_ingredients} leftover ingredients. Suggested baking items: #{suggested_good}"
  end
end

p serving_size_calc("pie", 7)
# p serving_size_calc("pie", 8)
# p serving_size_calc("cake", 5)
# p serving_size_calc("cake", 7)
# p serving_size_calc("cookie", 1)
# p serving_size_calc("cookie", 10)
# p serving_size_calc("THIS IS AN ERROR", 5)


#  Reflection

# What did you learn about making code readable by working on this challenge?
# Since I was solo for this challenge (had to makeup gps), I ended up doing pseudocode based on the code that was already written. That was something I hadn't done before, and it was helpful to break into steps in this way.

# Did you learn any new methods? What did you learn about them?
# I ended up using .include? since it fit well.

# What did you learn about accessing data in hashes?
# You can choose to access a key or value when calling a hash.

# What concepts were solidified when working through this challenge?
# Practicing "reverse" pseudocode was helpful for me!
{'fraction_non_alphanumeric': 0.07763157894736843, 'fraction_numerical': 0.007894736842105263, 'mean_word_length': 4.374747474747474, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '3339391', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1543, 'n_words': 668}