On Thu, 17 Feb 2022 02:20:53 -0800 (PST), NArshad <narshad....@gmail.com> declaimed the following:
>I have completed the homework or what so ever it used to be its only I am >telling the solution which looks to me as better as compared to what others >have given like the one that Christian has given. This statement should probably have been how you introduced the prior post instead of presenting something that read like a request for someone to implement something based on your new description. Your immediately prior post: >The feed remaining of the second hour will be distributed and adjusted in the >next third and fourth hour not the next day because the fish must be hungry. >This can be done by both taking the average or the percentage left. What I >think is taking the average and then distributing in the third and fourth feed >is better. If the feed is given in the next day there is a chance that the >fish will not survive because the fish is special. "If the feed is given in the next day..." is a non-issue, as the original problem description (shown here)... >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. ... explicitly states that the total amount must be provided within a single day. Since you didn't provide your implementation (or even just the resultant feeding pattern), I can not determine exactly what you are doing with regards to your "average" -- however, it seems to me that your "average" distribution "in the third and fourth feed" fails both the "rest of the day" and "try to keep the distribution similar..." requirements. It is a given that you have to account for the 40 units that were not provided in the second hour. It sounds very much like you are dumping them at 20&20 on the 3rd&4th hours, so your pattern (with the "error" feed now looks like 150 60 50 50 30 20 20 10 5 5 A proportional solution would result in the full pattern looking (ignoring round-off errors) 150 60 38 38 38 25 25 13 6 6 (round-off means you have to account for 1 more unit -- I'd probably put it on the first 38 hour, but that's only because I hand worked the proportions on a calculator. A "proper" algorithm should probably be tracking the error amounts [difference between integer units and real proportion] to apply the round-off at the nearest correct location). Taking error term into account units calc error 150 60 38 8.0 0.0 38 8.0 0.0 38 8.0 0.0 25 5.333 .333v 25 5.333 .666v 13 2.666 1.333^ .333 6 1.333 .666v 7 1.333 .999^ (I'm only showing 3 decimal places) Of course, one could compute the data in the other direction and get 6 1.333 .333v 6 1.333 .666v 13 2.666 1.333^ .333 25 5.333 .666v 26 5.333 .999^ (again, 3 decimal places) 0.0 38 8.0 0.0 38 8.0 0.0 38 8.0 0.0 60 150 (v = round down, ^ round up -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list