<commit_before># Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
  # create hash
  # add items to hash
  # set quantity to zero
  # print the list to the console [can you use one of your other methods here?]
# output: hash

# Method to add an item to a list
# input: item name and optional quantity
#steps:
# output:

# Method to remove an item from the list
# input:
# steps:
# output:

# Method to update the quantity of an item
# input:
# steps:
# output:

# Method to print a list and make it look pretty
# input:
# steps:
# output:

def create_list(grocery_list)
    new_list = Hash.new
    grocery_list.split(' ').each do |item|
    #array = grocery_list.split(' ')
    #array.each do |item|
    add_item(item, new_list)
    end
    print_list(new_list)
end

def add_item(item, list, quantity=0)
  list[item] = quantity
  p list
end

def remove_item(item, list)
  list.delete(item)
  p list
end

def update_quantity (item, list, quantity)
  list[item] = quantity
  p list
end

def print_list (list)
  list.each do |item, quantity|
    puts item.to_s + ": " + quantity.to_s
  end
end


# DRIVER CODE
katys_list = create_list("apples bananas")
add_item("carrots", katys_list, 3)
remove_item("apples", katys_list)
update_quantity("bananas", katys_list, 7)
print_list(katys_list)<commit_msg>Complete reflection for GPS 2.2<commit_after># Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
  # create hash
  # add items to hash
  # set quantity to zero
  # print the list to the console [can you use one of your other methods here?]
# output: hash


def create_list(grocery_list)
    new_list = Hash.new
    grocery_list.split(' ').each do |item|
    add_item(item, new_list)
    end
    print_list(new_list)
end

def add_item(item, list, quantity=0)
  list[item] = quantity
  p list
end

def remove_item(item, list)
  list.delete(item)
  p list
end

def update_quantity (item, list, quantity)
  list[item] = quantity
  p list
end

def print_list (list)
  list.each do |item, quantity|
    puts item.to_s + ": " + quantity.to_s
  end
end


# Release 3
my_list = create_list("onions")
update_quantity("onions", my_list, 1)
add_item("lemonade", my_list, 2)
add_item("tomatoes", my_list, 3)
add_item("ice cream", my_list, 4)
remove_item("lemonade", my_list)
update_quantity("ice cream", my_list, 1)
my_list.each do |item, quantity|
  puts "#{item}: #{quantity}"
end

# Release 4: N/A

# Release 5: Reflection:

# We started a bit late due to my pair having some technical difficulties, so our guide allowed us to skip
# some of the pseudocoding. It seemed like pseuocode was useful for the first method, but the remaining
# methods were so short that it really didn't seem necessary.

# We preferred to use hashes rather than arrays here, since we wanted to track both items and their
# quantities.

# A method will return a value of some sort. If no value is explicitly returned, it will return the last listed value # within the method.

# You can pass any sort of object into a method - arrays, hashes, strings, numbers, etc.

# To pass information between methods, you can store this information in hashes or arrays.

# This challenge was pretty straightforward, although I am still getting a hang of the syntax for hashes.

{'fraction_non_alphanumeric': 0.08945022288261516, 'fraction_numerical': 0.004160475482912333, 'mean_word_length': 4.061654135338346, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '5128002', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1079, 'n_words': 441}