From f4cbe15e3fe8879c71c8b484afe3587c50e7899c Mon Sep 17 00:00:00 2001 From: Anna Date: Wed, 19 Feb 2020 19:15:30 -0500 Subject: [PATCH 1/2] mvp day 1 --- eating_cookies/eating_cookies.py | 9 +++++++-- making_change/making_change.py | 10 +++++++++- recipe_batches/recipe_batches.py | 17 ++++++++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/eating_cookies/eating_cookies.py b/eating_cookies/eating_cookies.py index 62655d803..1ac18c525 100644 --- a/eating_cookies/eating_cookies.py +++ b/eating_cookies/eating_cookies.py @@ -5,8 +5,13 @@ # The cache parameter is here for if you want to implement # a solution that is more efficient than the naive # recursive solution -def eating_cookies(n, cache=None): - pass +def eating_cookies(n): + if n == 0: + return 1 + elif n < 1: + return 0 + else: + return eating_cookies(n-1) + eating_cookies(n-2) + eating_cookies(n-3) if __name__ == "__main__": if len(sys.argv) > 1: diff --git a/making_change/making_change.py b/making_change/making_change.py index 9adad4470..ef1ef09d8 100644 --- a/making_change/making_change.py +++ b/making_change/making_change.py @@ -2,8 +2,16 @@ import sys +total = 0 +count = 0 +sub_count = 1 + def making_change(amount, denominations): - pass + test = [1] + [0] * (amount) + for index in denominations: + for place in range(index, amount +1): + test[place] = test[place] + test[place - index] + return test[amount] if __name__ == "__main__": diff --git a/recipe_batches/recipe_batches.py b/recipe_batches/recipe_batches.py index c845950c5..894cfa491 100644 --- a/recipe_batches/recipe_batches.py +++ b/recipe_batches/recipe_batches.py @@ -3,7 +3,22 @@ import math def recipe_batches(recipe, ingredients): - pass + batches = -1 + no_more_ingredients = False + + while no_more_ingredients == False: + batches +=1 + + for item in recipe: + if item in ingredients.keys(): + if recipe[item] <= ingredients[item]: + ingredients[item] -= recipe[item] + else: + no_more_ingredients = True + break + + + return batches if __name__ == '__main__': From 6702d146c234358e95d29e4a8f806327bfc3993e Mon Sep 17 00:00:00 2001 From: Anna Date: Thu, 20 Feb 2020 18:51:23 -0500 Subject: [PATCH 2/2] day two, will require all nighter for sprint tomorrow blessed to have finished todays lol --- rock_paper_scissors/rps.py | 21 +++++++++++++++++++++ stock_prices/stock_prices.py | 14 +++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/rock_paper_scissors/rps.py b/rock_paper_scissors/rps.py index 0fc53356e..a8feb7a3e 100644 --- a/rock_paper_scissors/rps.py +++ b/rock_paper_scissors/rps.py @@ -2,8 +2,29 @@ import sys +def rps_recursion(number, list): + if number == 0: + return number + + def rock_paper_scissors(n): pass + result_array = [] + selection = ['rock', 'paper', 'scissors'] + + def recursive_listing(iterations, result=[]): + if iterations == 0: + return result_array.append(result) + for choice in selection: + recursive_listing(iterations -1, result + [choice]) + + recursive_listing(n) + return result_array + + + + + if __name__ == "__main__": diff --git a/stock_prices/stock_prices.py b/stock_prices/stock_prices.py index 9de20bc94..bf6dd3e11 100644 --- a/stock_prices/stock_prices.py +++ b/stock_prices/stock_prices.py @@ -3,7 +3,19 @@ import argparse def find_max_profit(prices): - pass + max_profit = 0 + stored_value = prices[0] + max_profit = prices[1]-prices[0] + index = 2 + while True: + if index > len(prices): + break + for price in prices[index-1:]: + if price - stored_value > max_profit: + max_profit = price - stored_value + stored_value=prices[index-1] + index += 1 + return max_profit if __name__ == '__main__':