Skip to content
This repository was archived by the owner on Jul 18, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion eating_cookies/eating_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 11 additions & 1 deletion making_change/making_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
18 changes: 17 additions & 1 deletion recipe_batches/recipe_batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions rock_paper_scissors/rps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 18 additions & 1 deletion stock_prices/stock_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down