Answer the question
In order to leave comments, you need to log in
Expand the number of checks by day, algorithm?
Hello, maybe the task is stupid, but I have a question.
There is a total number of checks, for example 800, and a week.
From Monday to Wednesday we work ten hours, on Thursday and Friday at 12, and on weekends at 4.
You can calculate the average number of checks per hour, and multiply by hours every day.
But it is necessary that there was an integer in each day.
For example, 3 elements remain after rounding. And how would they be decomposed among the largest.
Greedy algorithms came to mind, but somehow the solution never came.
If you only sort by max hours, and drop one by one in descending order.
I would like, for example, for a case, for example, at the top it will be 18 hours, and after it 12 hours, and it would be logical to throw 2 checks at 18, and 1 check at 10 and other guesses
Answer the question
In order to leave comments, you need to log in
It seems to me something like this:
1) Count the number of hours in a week
10 + 10 + 10 + 12 + 12 + 4 + 4 = 62
2) Divide with the remainder (in php look at the% sign) the number of checks for the number of hours
800 / 62 = 12 and the remainder 56
3) Calculate the ratio of hours in days from the total amount
10 / 62 = 0.1613
12 / 62 = 0.1935
4
/
62 = 0.0645 .03 (Mon, Tue, Wed)
56
* 0.1935 = 10.84 (Thu, Fri)
56 * 0.0645 = 3.61 (Sat, Sun
) fold and repeat step 4
it’s difficult without formalization by one stream of consciousness
, but 56 checks that remain after sharing 800 for 62 hours can be divided completely by the weight of the days, rounded down - so that weekends do not always get added
If you really need an answer to your question, then get together and try to formulate it again :)
There is a certain number of checks, this is understandable.
There is a work schedule, this is also understandable.
You can calculate the average number of checks per hour, and multiply by the hours in each day.
But it is necessary that there was an integer in each day.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question