Forked from styx97/gist:542dc6eabcdbab2901e91af118e80258
Last active
January 23, 2017 19:03
-
-
Save hiraksarkar/c48fb26533cb83774561ce7c3a9ec058 to your computer and use it in GitHub Desktop.
Solving problems in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [1,4,5,10] | |
cache = {} | |
for i in a: | |
cache[i] = 1 | |
counter = 0 | |
#okay khub bhalo code hoyeche | |
def coin(x): | |
if not x in cache: | |
tmp = [] | |
for i in a: | |
if (x-i) > 0: | |
if (x-i) in cache: | |
tmp.append(1+cache[x-i]) | |
else: | |
tmp.append(1+coin(x-i)) | |
cache[x] = min(tmp) | |
return cache[x] | |
else: | |
return cache[x] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment