How to solve the given problem?
Christian Gollwitzer
auriocus at gmx.de
Thu Feb 10 02:30:15 EST 2022
Am 10.02.22 um 07:40 schrieb NArshad:
>
> Assume that there is a pattern of feeding for a special fish in a day (10 hours a day) as below:
> 150 100 30 30 30 20 20 10 5 5
> Today, the fish is fed in the second hour 60 unit instead of 100 unit Accidently. Implement some methods to distribute the remaining 40 unit in the rest of the day and propose the new patterns. Try to keep the distribution similar to the current feeding pattern.
> Note: pay attention that the total feeding amounts should be fix in a day.
This is not a Python problem, it's a math problem and most probably a
homework problem. Actually the question already tells you how to solve
it. There are 40 units of fish-food left and you should distribute them
proportionally to the rest of the day. Sum up the numbers from 3rd to
last, add 40, and then distribute this to proportionally to each day.
You'll end up with fractinoal numbers in the general case, so you'll
have to find a method to fairly distribute the units, if you wan to
stick with integers.
You can also check out the various algorithms for distributing seats in
a parliament, it is almost the same problem.
Christian
More information about the Python-list
mailing list