How many times should I jump each day, before and after 9 PM, so I have the same number of jumps every day in both time zones (UTC and GMT -3)?

75 Views Asked by At

I'm counting jumps. My jumps are timestamped, and I have the jump count on both UTC time zone and GMT -3 time zone (my time zone). The jump counts are:

Day UTC GMT -3
Sunday 658 672
Monday 704 701
Tuesday 696 756
Wednesday 727 680
Thursday 738 740
Friday 688 669
Saturday 699 692

How many jumps should I jump each day on my time zone, before and after 9 PM (21h00), so I have the same number of jumps every day in both time zones (UTC and GMT -3)? How can I model this problem?

The number of jumps must be the same across all days of the week (ie. Sunday, Monday, Tuesday, etc, must all be "756" or "787", as long as they are all the same number). Also, I noticed that as the total sum of jumps must be the same on UTC and GMT -3, the numbers must also be the same on every cell of the table.

As an additional information implicit by the time zones, if I jump once on Sunday at 1 PM my time (4 PM UTC), my Sunday jump count will be 659 for UTC and 673 for GMT -3. If, on the other hand, I jump once on Sunday at 10 PM my time (1 AM Monday UTC), my jump count on Sunday will be 658 for UTC, 673 for GMT -3 and also my jump count on Monday will be 705 for UTC.

Example

Imagining a 3-day week, this:

Day UTC GMT -3
Sunday 3 2
Monday 1 2
Tuesday 1 1

gets partially solved by this:

Day bef. 9 PM aft. 9 PM
Sunday 0 1
Monday 0 0
Tuesday 0 0

making the table look like this:

Day UTC GMT -3
Sunday 3 3
Monday 2 2
Tuesday 1 1

and from this point forward, the solution to equalize every number is trivial by adding jumps before 9 PM, which add the jump count for each day on both time zones:

Day bef. 9 PM aft. 9 PM
Sunday 0 0
Monday 1 0
Tuesday 2 0

finally making the table:

Day bef. 9 PM aft. 9 PM
Sunday 3 3
Monday 3 3
Tuesday 3 3

The final solution is the sum of each partial table:

Day bef. 9 PM aft. 9 PM
Sunday 0 1
Monday 1 0
Tuesday 2 0
1

There are 1 best solutions below

0
On

This can be solved by dividing the problem into two partial problems: calculate jumps done after 9 PM, to even the jump count on every day in both time zones (lines of the table); then jumps done before 9 PM, to even the jump count across all days.

As jumping before 9 PM equally changes the counter on both time zones, it is useless trying to find jumps considering jumps done at this time. Considering an initial state with 0 jumps in all days, jumps done after 9 PM are the only ones which can disturb the balance between time zones.

For the first part of the problem, the following algorithm solves the problem:

func(GMT_3,UTC):
1. initialize post9pm = [0,0,0,0,0,0,0]
2. while (GMT_3 != UTC):
3.   iterate through every day:
4.     if (GMT_3[day] > UTC[day])
4.       jump_diff = GMT_3[day] - UTC[day]
5.       post9pm[(day - 1)] = jump_diff
6.       UTC[(day - 1)] += jump_diff
7.       GMT_3[day] += jump_diff
8.       if (GMT_3 == UTC):
9.         break

It works by comparing the jump count on the current week day on the GMT -3 and UTC time zones. If there are more jumps on GMT -3, the difference is compensated by adding the jumps needed post 9 PM in the previous week day. It will count as jumps on the previous week day on GMT -3, but it will even the number of jumps in the current week day.

After both time zones have the same number of jumps in each week day (each line of the first table), we simply find the day with most jumps and add the difference to each week day by jumping that count before 9 PM.

Example:

The original problem is:

Day UTC GMT -3
Sunday 658 672
Monday 704 701
Tuesday 696 756
Wednesday 727 680
Thursday 738 740
Friday 688 669
Saturday 699 692

After running the jump counts through the algorithm we get:

Day bef. 9 PM aft. 9 PM
Sunday 0 57
Monday 0 60
Tuesday 0 0
Wednesday 0 47
Thursday 0 45
Friday 0 64
Saturday 0 71

and

Day UTC GMT -3
Sunday 729 729
Monday 761 761
Tuesday 756 756
Wednesday 727 727
Thursday 785 785
Friday 733 733
Saturday 763 763

After that, we simply add jumps before 9 PM so all week days equal to the largest day count (Thursday in this example):

Day bef. 9 PM aft. 9 PM total
Sunday 56 57 113
Monday 24 60 84
Tuesday 29 0 29
Wednesday 58 47 105
Thursday 0 45 45
Friday 52 64 116
Saturday 22 71 93

making a total of 545 additional jumps and:

Day UTC GMT -3
Sunday 785 785
Monday 785 785
Tuesday 785 785
Wednesday 785 785
Thursday 785 785
Friday 785 785
Saturday 785 785