N
N
nyatmeat152018-12-28 22:40:57
Algorithms
nyatmeat15, 2018-12-28 22:40:57

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

3 answer(s)
M
Marat Garifullin, 2018-12-28
@nyatmeat15

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

D
Dimonchik, 2018-12-28
@dimonchik2013

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

Z
Zanak, 2018-12-29
@Zanak

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.

You may or may not count. What is ultimately needed? Estimate the number of buyers at different points in time? Or is it plausible to scatter the number of checks by day?
If you give an example of the calculation, then be careful in its presentation. The initial data contains the numbers 4, 10 and 12 hours, where did 18 come from?
If we talk about the idea of ​​assigning weights to days, I would try this:
- count the weights in the 10+10+10+4+4 group, and scatter what is left of the 12+12 group according to them
- then I would distribute the remains from the group 10 + 10 + 10 for a pair of 4 + 4
- the indivisible remainder of the group 4 + 4 (this is from 0 to 3 checks) would simply be discarded

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question