Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python list exercize
#1
Hello I'm in high school(I guess, I Don't really know to what it correspond since I'm french) and I've got this excercize which I can't get through. Here is the translated version :

Quote:Exercise 3.2
A burglar breaks into a house. He is only able to carry a limited mass: he will therefore have to choose between different valuables, in order to collect the biggest loot possible.

1. Write an algorithm that gives an optimal choice for the thief.

2. Program in Python language a fill function whose prototype is as follows: fill (list: list, mass: int)
• list - list of items (price, mass)
• mass - maximum mass
We have a list of objects of masses m = [9, 10, 12, 14, 11, 5, 7, 5, 6, 2] as well as their associated values v = [10, 8, 7, 7, 5, 4, 3 , 2, 2, 1].

3. Test the program for a maximum mass of 22 kg. Conclude.


So, my biggest problem here is the task about taking the biggest loot possible, 'cause it means that you have to associate different valuables in order to make the biggest loot possible whithout exceeding the threshold. And I Don't know how to do this. That's why I'm asking if you could help me if it's not too much of a bother.
Thanks in advance !
Reply


Messages In This Thread
Python list exercize - by ESTOUR - May-23-2020, 04:50 PM
RE: Python list exercize - by michael1789 - May-23-2020, 06:37 PM
RE: Python list exercize - by jefsummers - May-23-2020, 08:16 PM
RE: Python list exercize - by ESTOUR - May-23-2020, 11:10 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020