U11Try3
This commit is contained in:
parent
dcc6f0811f
commit
39318b5acb
@ -1,4 +1,5 @@
|
|||||||
def maximum_value(maximum_weight, items):
|
def maximum_value(maximum_weight, items):
|
||||||
|
#всі перевірки на перші 2 тести
|
||||||
if maximum_weight == 0:
|
if maximum_weight == 0:
|
||||||
return 0
|
return 0
|
||||||
if items == 0 or items is None or items ==[]:
|
if items == 0 or items is None or items ==[]:
|
||||||
@ -8,6 +9,17 @@ def maximum_value(maximum_weight, items):
|
|||||||
weight = curent_dic.get("weight")
|
weight = curent_dic.get("weight")
|
||||||
if weight > maximum_weight:
|
if weight > maximum_weight:
|
||||||
return 0
|
return 0
|
||||||
|
#ділимо на лісти
|
||||||
|
weight = []
|
||||||
|
value = []
|
||||||
|
i = 0
|
||||||
|
while i < len(items):
|
||||||
|
curent_dic = items[i]
|
||||||
|
weight.append(curent_dic.get("weight"))
|
||||||
|
value.append(curent_dic.get("value"))
|
||||||
|
i +=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def maximum_value_with_items(maximum_weight, items):
|
def maximum_value_with_items(maximum_weight, items):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user