From b2c51f091c61012d0f496d468a21aedbf85c658f Mon Sep 17 00:00:00 2001 From: JustSpokenCodes Date: Tue, 4 Feb 2020 19:32:50 -0800 Subject: [PATCH 1/5] making the cookies --- eating_cookies/eating_cookies.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/eating_cookies/eating_cookies.py b/eating_cookies/eating_cookies.py index 62655d803..518cae4f9 100644 --- a/eating_cookies/eating_cookies.py +++ b/eating_cookies/eating_cookies.py @@ -6,7 +6,18 @@ # a solution that is more efficient than the naive # recursive solution 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: From 1e8c7495c39055c0aafc8be7c02bb354c98f4aef Mon Sep 17 00:00:00 2001 From: JustSpokenCodes Date: Tue, 4 Feb 2020 19:36:55 -0800 Subject: [PATCH 2/5] making change --- making_change/making_change.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/making_change/making_change.py b/making_change/making_change.py index 9adad4470..b887056fe 100644 --- a/making_change/making_change.py +++ b/making_change/making_change.py @@ -2,8 +2,18 @@ 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__": From 11eead027fd0f2135c142a1a0dccd16cdea89eeb Mon Sep 17 00:00:00 2001 From: JustSpokenCodes Date: Tue, 4 Feb 2020 19:41:59 -0800 Subject: [PATCH 3/5] I cant get this false for recipes --- recipe_batches/recipe_batches.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/recipe_batches/recipe_batches.py b/recipe_batches/recipe_batches.py index c845950c5..09b584312 100644 --- a/recipe_batches/recipe_batches.py +++ b/recipe_batches/recipe_batches.py @@ -3,8 +3,24 @@ 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 + else: + no_more_ingredients = True + break + + return batches if __name__ == '__main__': # Change the entries of these dictionaries to test From 05d1581ddc48b7a311805a0a27481cc1247af6e9 Mon Sep 17 00:00:00 2001 From: JustSpokenCodes Date: Thu, 6 Feb 2020 19:19:41 -0800 Subject: [PATCH 4/5] i think this is how you play rps --- rock_paper_scissors/rps.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/rock_paper_scissors/rps.py b/rock_paper_scissors/rps.py index 0fc53356e..68c818354 100644 --- a/rock_paper_scissors/rps.py +++ b/rock_paper_scissors/rps.py @@ -2,9 +2,22 @@ import sys -def rock_paper_scissors(n): - pass +validMoves = [['rock'], ['paper'], ['scissors']] +def rock_paper_scissors(n) + if n == 0: + return [[]] + if n == 1: + return validMoves + + output = [] + arr = rock_paper_scissors(n -1) + for subArr in arr: + for move in validMoves: + newMove = subArr + move + output.append(newMove) + + return output if __name__ == "__main__": if len(sys.argv) > 1: From ecacbfd30154b522f98bae8f38812c1e36ee4546 Mon Sep 17 00:00:00 2001 From: JustSpokenCodes Date: Thu, 6 Feb 2020 19:26:52 -0800 Subject: [PATCH 5/5] stock prices up --- stock_prices/stock_prices.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/stock_prices/stock_prices.py b/stock_prices/stock_prices.py index 9de20bc94..3108d5f12 100644 --- a/stock_prices/stock_prices.py +++ b/stock_prices/stock_prices.py @@ -3,7 +3,24 @@ import argparse def find_max_profit(prices): - pass + if len(prices) < 2: + return 0 + + # set intial lowest and maxProfit values from array values + lowest = prices[0] + maxProfit = prices[1] - prices[0] + + # for each item in prices + for i in range(1, len(prices)): + price = prices[i] + # each new item, find out the difference from the current item and the lowest prev price + profitFromTrade = price - lowest + # track the lowest price + lowest = min(lowest, price) + # save the max, positive difference + maxProfit = max(profitFromTrade, maxProfit) + # return max when finished + return maxProfit if __name__ == '__main__':