steve at pearwood.info
Fri Mar 4 01:32:48 CET 2011
James Reynolds wrote:
> You are almost assuredly going to get flamed for not having a descriptive
> title and for asking what is obviously homework questions
At least Andrew did the right thing by being honest that it was a
homework question, and by showing the work he's done so far.
But yes, you're right, a more descriptive title is always appreciated.
And speaking for flaming, thank you for not top-posting in the future.
If you *must* top-post, because you're using one of those stupid "smart"
phones that won't let you do otherwise, at least apologize for doing so.
Andrew, you ask:
>> but how would i add the 5 min and 13 seconds after 143 items have
>> been produced???
You should always do all your calculations in a single unit of time
(probably seconds), and only convert back to D HH:MM:SS at the very end.
If you have N items to produce, you need to consider it broken up into
groups of 143 items, plus cooling off time *between* each group. If N is
an exact multiple of 143 items, you have something like this:
Notice that you don't care about the cooling off time after you're done.
If N is not an exact multiple, there will be some remainder:
You can work out the number of groups of 143, and the remainder left
over, using the divmod function. Then you can work out the number of
cooling periods -- this is just the fence post problem. If you have a
fence with N posts |===|===|===|===|===|===|===|===|===| how many
sections are there? Or conversely, given M sections of a fence, how many
posts do you need?
More information about the Tutor