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.

        At the risk of irritating the other regulars... If you've completed it,
why not show us your Python code so we may review it? I presume you did do
it in Python.

        I'm not going to show my code -- mainly as I just spent today writing a
solution in REXX. But I will show the results of running said code. My
solution is GENERAL in that it handles
1       variable number of periods in the plan
2       variable number of periods in the actual (partial day)
3       the case where the mis-feed is not the last item in actual
4       the case where the actual matches the plan (no mis-feed)
5       the case where the mis-feed is a shortage (underfed)
6       the case where the mis-feed is an overage (overfed)
7       the case where multiple mis-feeds cancel out (not shown below)

-=-=-   Your example schedule and feed amounts
C:\Users\Wulfraed\Documents\_Hg-Repositories\REXX>rexx feedme.rex

Enter planned feeding schedule (feed units for each time period, space
separated)
150 100 30 30 30 20 20 10 5 5

Enter actual feeding schedule up to current feed period
150 60

PLAN    :  10 time periods 400 total feed units
ACTUAL  :  2 time periods 210 total feed units dispensed
MIS-FEED:  40 underfed

SCHEDULE:  150 60 39 38 38 25 25 13 6 6

-=-=-   Same, but the mis-feed was not discovered until after the 3rd
period
C:\Users\Wulfraed\Documents\_Hg-Repositories\REXX>rexx feedme.rex

Enter planned feeding schedule (feed units for each time period, space
separated)
150 100 30 30 30 20 20 10 5 5

Enter actual feeding schedule up to current feed period
150 60 30

PLAN    :  10 time periods 400 total feed units
ACTUAL  :  3 time periods 240 total feed units dispensed
MIS-FEED:  40 underfed

SCHEDULE:  150 60 30 40 40 27 27 13 7 6

-=-=-   An example were the mis-feed was in the other direction
C:\Users\Wulfraed\Documents\_Hg-Repositories\REXX>rexx feedme.rex

Enter planned feeding schedule (feed units for each time period, space
separated)
150 100 30 30 30 20 20 10 5 5

Enter actual feeding schedule up to current feed period
150 120

PLAN    :  10 time periods 400 total feed units
ACTUAL  :  2 time periods 270 total feed units dispensed
MIS-FEED:  20 overfed

SCHEDULE:  150 120 27 26 26 17 17 9 4 4

-=-=-   Finally, an example where there was no mis-feed
C:\Users\Wulfraed\Documents\_Hg-Repositories\REXX>rexx feedme.rex

Enter planned feeding schedule (feed units for each time period, space
separated)
150 100 30 30 30 20 20 10 5 5

Enter actual feeding schedule up to current feed period
150 100

PLAN    :  10 time periods 400 total feed units
ACTUAL  :  2 time periods 250 total feed units dispensed
MIS-FEED:  0 on schedule

C:\Users\Wulfraed\Documents\_Hg-Repositories\REXX>


-- 
        Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfr...@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to