[…] The task requires, that I need to use the most weight in the lift that doesn't exceed 500kg. […]
If you want to “cheat”, this kind of task is known as
backpack problem (except that your “backpack” is an elevator and all “items” have a constant value, since you merely want to maximize the number of people). By the mere length of the English Wikipedia page you can infer it’s not a
simple task.
Now, obviously your class isn’t about finding the mathematically best and efficient solution, though, so ideally do
just what winni already suggested:
[…]
You have to check
2+3+4+5 =
1+3+4+5 =
[…]
That’s the brute-force approach. From your code I can see you already know enough to achieve that. You know how to access array components and how to use
for-loops. The difficult thing is maybe to generate all possible passenger combinations, to
construct a power set.