Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiraksarkar/c48fb26533cb83774561ce7c3a9ec058 to your computer and use it in GitHub Desktop.
Save hiraksarkar/c48fb26533cb83774561ce7c3a9ec058 to your computer and use it in GitHub Desktop.
Solving problems in python
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