From 433285e569e932a36a91089e9c3a7ee70edebd30 Mon Sep 17 00:00:00 2001 From: cappers86 <52895127+cappers86@users.noreply.github.com> Date: Wed, 15 Apr 2020 13:33:03 +0100 Subject: [PATCH 1/3] Stock prices test passing --- stock_prices/stock_prices.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/stock_prices/stock_prices.py b/stock_prices/stock_prices.py index 9de20bc94..f7a4ab9bf 100644 --- a/stock_prices/stock_prices.py +++ b/stock_prices/stock_prices.py @@ -1,9 +1,24 @@ #!/usr/bin/python +### whats the problem we have a list of numbers, and we need to check which number is the biggest in the list then store and compare +## this index to the number with the lowest index and then take the lowest from the highest + import argparse def find_max_profit(prices): - pass + mp = [0] ## set max profit to initial 0 + + for i in range(0, len(prices) -1): ## getting the initial value from mp to the last element + ci = i ## define index + + for x in range(ci + 1, len(prices) -1): ## initiate the check from initial index to last index -1 + if prices[x] - prices[ci] > mp[0]: ## subtract current index from the index we have in prices + mp[0] = prices[x] - prices[ci] + + elif prices[x] - prices[ci] < 0 and mp[0] == 0: ## if we hit negative numbers + mp[0] = prices[x] - prices[ci] + + return mp[0] if __name__ == '__main__': From 456b683df364b7554b6b922a1d941147a4ebb213 Mon Sep 17 00:00:00 2001 From: cappers86 <52895127+cappers86@users.noreply.github.com> Date: Thu, 16 Apr 2020 13:22:21 +0100 Subject: [PATCH 2/3] For got to commit yesterday --- recipe_batches/recipe_batches.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/recipe_batches/recipe_batches.py b/recipe_batches/recipe_batches.py index c845950c5..2e9779cf4 100644 --- a/recipe_batches/recipe_batches.py +++ b/recipe_batches/recipe_batches.py @@ -1,9 +1,23 @@ #!/usr/bin/python +## whats the question asking: how many batches of a recipe can we make from th input of 2 dictionaries dic1(recipes), dic2(ingreidents) +## with this in mind we need to input both dictionaries and return the maxium batches possible may be // +## https://www.w3schools.com/python/python_sets.asp +##https://www.w3schools.com/python/ref_func_min.asp + import math def recipe_batches(recipe, ingredients): - pass + if set(recipe) == set(ingredients): ## check to see if we have the correct ammount of ingredients to make a single or multiple bacthes + batches =[] + for i in recipe: ## check how many if any ammount of batches can be made from what we have avaible + if ingredients[i] >= recipe[i]: + consumed = ingredients[i] // recipe[i] + batches.append(consumed) + return min(batches) ## this will show us what is the minium ammount of batches we can make + ## we need to make a case senario for when there is not enough to make any batches using else and have the return be zero + else: + return 0 if __name__ == '__main__': From aa99c5c59ef3ae29a888c85b298976df0fd4ed78 Mon Sep 17 00:00:00 2001 From: cappers86 <52895127+cappers86@users.noreply.github.com> Date: Thu, 16 Apr 2020 16:32:48 +0100 Subject: [PATCH 3/3] cookies --- eating_cookies/eating_cookies.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/eating_cookies/eating_cookies.py b/eating_cookies/eating_cookies.py index 62655d803..964204a12 100644 --- a/eating_cookies/eating_cookies.py +++ b/eating_cookies/eating_cookies.py @@ -5,8 +5,23 @@ # The cache parameter is here for if you want to implement # a solution that is more efficient than the naive # recursive solution + +##eating cookies is going to allow us to figure out how many Ways there are to eating cookies +## n is effictbley cookies with 1,1,1 1,2 2,1 3 def eating_cookies(n, cache=None): - pass + count = 0 + if n == 0 or n == 1: + return 1 + elif n == 2: + return 2 + else: + arr = [1, 1, 2] + for number in range(3, n+1): + count = arr[-3] + arr[-2] + arr[-1] + arr.append(count) + + return count + if __name__ == "__main__": if len(sys.argv) > 1: