def knapsack():
capacity = 41
matrix = [(1, 12.34, 123.99),(2, 23.45, 600.54),(3, 12.78, 90.67), (4, 9.34, 45.32)]
matrix = sorted(matrix, key=lambda object: object[1]/object[2])
i = 0
while capacity > 0:
if capacity > matrix[i][1]:
capacity -= matrix[i][1]
i+=1
else:
capacity = -capacity
output = ""
for k in range(0, i):
output += str(matrix[k][0]) + " "+ str(matrix[k][1]) + " " + str(matrix[k][2]) + " complete"
if capacity < 0:
output += str(matrix[i][0]) + " "+ str(matrix[i][1]) + " " + str(matrix[i][2]) + " "+ str(capacity) + "fractional"
print(output)
knapsack()
ZGVmIGtuYXBzYWNrKCk6CgogICAgY2FwYWNpdHkgPSA0MQoKICAgIG1hdHJpeCA9IFsoMSwgMTIuMzQsIDEyMy45OSksKDIsIDIzLjQ1LCA2MDAuNTQpLCgzLCAxMi43OCwgOTAuNjcpLCAoNCwgOS4zNCwgNDUuMzIpXQoKICAgIG1hdHJpeCA9IHNvcnRlZChtYXRyaXgsIGtleT1sYW1iZGEgb2JqZWN0OiBvYmplY3RbMV0vb2JqZWN0WzJdKQoKICAgIGkgPSAwCgogICAgd2hpbGUgY2FwYWNpdHkgPiAwOgoKICAgICAgICBpZiBjYXBhY2l0eSA+IG1hdHJpeFtpXVsxXToKICAgICAgICAgICAgY2FwYWNpdHkgLT0gbWF0cml4W2ldWzFdCiAgICAgICAgICAgIGkrPTEKICAgICAgICBlbHNlOgogICAgICAgICAgICBjYXBhY2l0eSA9IC1jYXBhY2l0eQoKICAgIG91dHB1dCA9ICIiCgogICAgZm9yIGsgaW4gcmFuZ2UoMCwgaSk6CgogICAgICAgIG91dHB1dCArPSBzdHIobWF0cml4W2tdWzBdKSArICIgIisgc3RyKG1hdHJpeFtrXVsxXSkgKyAiICIgKyBzdHIobWF0cml4W2tdWzJdKSArICIgY29tcGxldGUiCgogICAgaWYgY2FwYWNpdHkgPCAwOgogICAgICAgIAogICAgICAgIG91dHB1dCArPSBzdHIobWF0cml4W2ldWzBdKSArICIgIisgc3RyKG1hdHJpeFtpXVsxXSkgKyAiICIgKyBzdHIobWF0cml4W2ldWzJdKSArICIgIisgc3RyKGNhcGFjaXR5KSArICJmcmFjdGlvbmFsIgogICAgICAgIAogICAgcHJpbnQob3V0cHV0KSAgICAgICAgCgprbmFwc2FjaygpICAgICAgICAK