Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def cont(i, sez):
- vsote = dict()
- def kovanci2(i,sez, vsote):
- '''
- Vrne optimalno vsoto kovancev. Vrne tudi indekse kovance, ki jih porabimo.
- Rekuzivno z memoizacijo.
- '''
- if i == 1:
- if i not in vsote:
- vsote[1] = sez[0]
- return vsote
- if i == 2:
- if i not in vsote:
- vsote[2] = (max(sez[0], sez[1]),i)
- return vsote
- if i not in vsote:
- najvecja = max(sez[i-1] + kovanci(i-2,sez),kovanci(i-1,sez))
- vsote[i] = (najvecja,i)
- return vsote
- return kovanci2(i,sez, vsote)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement