Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit afaefb9

Browse files
tiny update
1 parent 6f893fa commit afaefb9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

‎EPI/EPI.py‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
22
solutions to problems in EPI
33
"""
4+
5+
46
#naive recursion
57
def cc(n, denoms):
68
minCoins =100
@@ -34,7 +36,7 @@ def greedyCC(n, denoms):
3436
Find the number of ways to make change, given an amount change and
3537
an array of denominations, coins.
3638
http://www.geeksforgeeks.org/dynamic-programming-set-7-coin-change/
37-
39+
"""
3840
def numberWaysMakeChange(change, coins):
3941
# We need n+1 rows as the table is consturcted in bottom up
4042
# manner using the base case 0 value case (n = 0)
@@ -57,14 +59,14 @@ def numberWaysMakeChange(change, coins):
5759
memo[i][j] = x + y
5860

5961
return memo[-1][-1]
60-
print(numberWaysMakeChange(10, [1, 5, 10, 25]))
61-
"""
62+
#print(numberWaysMakeChange(10, [1, 5, 10, 25]))
63+
6264
"""
6365
8/14/17
6466
Giving an amount of change and a list of available denominations, coins, find the minimum
6567
number of coins required to make c. makeChange is the optimized version of
6668
makeChange1, my original solution
67-
69+
"""
6870
def makeChange(change, coins):
6971

7072
memo=[0]+[1000] * (change)
@@ -74,7 +76,7 @@ def makeChange(change, coins):
7476
memo[amount]= min(memo[amount-c]+1, memo[amount])
7577
return memo[-1]
7678

77-
print(makeChange(25, [1, 2, 5, 10]))
79+
#print(makeChange(25, [1, 2, 5, 10]))
7880

7981

8082
def makeChange1(change, coins):
@@ -86,13 +88,13 @@ def makeChange1(change, coins):
8688
memo[amount]= memo[amount-c]+1
8789
return memo[-1]
8890

89-
print(makeChange1(25, [1, 2, 5, 10]))
90-
"""
91+
#print(makeChange1(25, [1, 2, 5, 10]))
92+
9193
"""
9294
8/4/17
9395
Buy and sell one share of stock, given the array of prices. Cannot
9496
short stock, (have to buy before selling). Return the max profit possible.
95-
97+
"""
9698

9799
# Brute force, use two nested loops, find max from every possible transaction.
98100
def maxProfit(prices):
@@ -115,6 +117,6 @@ def maxProfit1(prices):
115117
maxProfit= max(maxProfit, prices[i]-lowestSoFar)
116118
return maxProfit
117119

118-
print(maxProfit1([20, 1, 9, 2, 10]))
119-
"""
120+
#print(maxProfit1([20, 1, 9, 2, 10]))
121+
120122

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /