How will Apple and Google provide 5-minute data on Covid exposures using 10-minute interval numbers in the hash?

The goal of COVID-19 exposure notification is to notify people that they were exposed to someone who later tested positive for the virus. Protecting privacy in this process requires some cryptography, and avoiding excessively granular detail on user locations. But providing data useful for disease prevention requires adequate detail in measuring the length of exposures.

There is a new API for such exposure notification from Apple and Google, but it has a tension between 5- and 10-minute numbers that I don’t see how to resolve.

The cryptography specification, v1.2.1, specifies 10-minute intervals as inputs to the hash: “in this protocol, the time is discretized in 10 minute intervals that are enumerated starting from Unix Epoch Time. ENIntervalNumber allows conversion of the current time to a number representing the interval it’s in.”

Meanwhile the FAQ, v1.1, specifies 5-minute increments in the output: “Public health authorities will set a minimum threshold for time spent together, such that a user needs to be within Bluetooth range for at least 5 minutes to register a match. If the contact is longer than 5 minutes, the system will report time in increments of 5 minutes up to a maximum of 30 minutes to ensure privacy.”

How will the system report times in 5-minute increments when the interval numbers are only updated for the hash once every 10 minutes?

Redirect page during a weekly time interval

I have a registration page ‘register’ which sends information to a third party server as part of a dual registration process. The 3rd party have a 2 hr weekly maintenance schedule every Friday 9-11pm CT. I wish to redirect users to a new page that just says you can’t register during this specified maintenance time period.

I am considering using the below added to functions.php. Is this the right approach, does it look like it would work? I don’t want to reset the entire site’s time zone either, as not in America, just for this usage.

add_action ( 'template_redirect', 'redirect_from_registration_maintenance' ); function redirect_from_registration_maintenance(){     date_default_timezone_set('America/Chicago');     $  hour = date('G');     $  minute = date('i');     $  day = date('w');     $  m = $  hour * 60 + $  minute; // Minutes since midnight. if ( !is_user_logged_in() && is_page( 'register' )   && $  day == 5 // Friday...   && $  m >= 1260 // ... after 9pm…   && $  m <= 1380 // ... but before 11pm… ) {     wp_redirect('') ; exit();     } } 


Add on interval, Query for number of elements less than val

We have an array of numbers and we are supposed to do the following queries on it:

  1. Add number x to all elements on the subarray with indices [ L, R ] of the array.
  2. Query for number of elements less than number x of the whole array.

I have a solution with time complexity $ O(q \cdot log(n) \cdot sqrt(n))$ where $ n$ is the size of the array and $ q$ is the number of the queries. However for constraints $ n, q < 1e5$ with time limit of 2 seconds this is not efficient enough. So how to solve it on these constraints?

Interval sorting that avoids covering

I have a collection of intervals and I want to sort them so that the order is interpreted as a sort of “z-index”. That is, a given interval may or may not be “visible” depending on whether the merge of the intervals to its left contains it.

I am looking for an algorithm to search the optimal ordering, that maximizes the number of visible intervals.

Context: the intervals are spans of text (that all contain a given keyword) and I want to color them using CSS cascading behavior so that all regions are at least partially visible.

Cover interval with minimum sum intervals – DP recursion depth problem

I have just found the official solutions online (have been looking for them for a while, but after posting this I quickly found it), and I’m currently trying to understand it. As I can tell, it uses a much simpler DP, which only uses an O(N) array.

This year I attended a programming competition, where we had a few interesting problems. I had trouble with some of them, and since the next round approaches, I want to clear them up.

The problem in a nutshell
We are given N weighted intervals, and a [A,B] interval. We have to cover the [A,B] interval with the given ones, in such a way, that we minimize the overall weight sum (and then the number of required intervals). We need to print the sum, the number of intervals, and then the intervals themselves. If we can not cover [A, B], we need to report that as a special value (-1).

First thoughts
If we sort the intervals by begin time, then we can do simple 0-1 Knapsack-like DP and solve the problem. Also, if the priorities were swapped (minimize count THAN sum), a simple greedy would do it.

The limits
Basically, all interval starts and ends are in the range 1-1 000 000, and N<=100 000. All intervals lie within [A,B].

My approach
I wrote a recursive algorithm like the 0-1 Knapsack one in python, that also stored the last selected interval – thus allowing the recovering of the selection list from the DP array later. It was a (current_interval, last_covered_day) -> (cost, last_selected_interval, last_covered_day')-like function. I used a dict as a DP array, as a regular array that big would have violated memory constraints and filling it fully would also increase runtime (at least that’s what I thought – but a 1000000 * 100000 array would certainly would!). I wrote the function as a recursive one so it would not fill in the entire DP array and be faster & more memory-efficient.

The problem with this
Simply, I got RecursionError: maximum recursion depth exceededs on larger datasets – 100k deep recursion was simply too much. I read since on GeeksForGeeks that it should be possible to increase it, but I am still not confident that it would be safe. My recursive function is also not tail-call optimizatiable, so that would also not work.

So my questions
Is there a way of solving this problem without DP? If no, is filling in a full table an option with those high limits? Maybe we can come up with a different DP approach that does not use such big tables? Is it safe to just increase recursion depth limits with this kinds of problems?

Runtime of weighted interval scheduling dynamic programming algorithm

Consider this implementation of a dynamic programming algorithm for weighted interval scheduling:

M-Compute-Opt(j)      If j=0 then          Return 0     Else if M[j] is not empty then          Return M[j]     Else         Define M[j] = max(v_j + M-Compute-Opt(p(j)), M-Compute-Opt(j − 1))          Return M[j]     Endif 

Here we have a set of requests $ \{1, 2, \ldots , j\}$ . We’re assuming they’re ordered by finishing time in nondecreasing order. I.e., $ j$ finishes last, $ j-1$ second last, etc. $ v_j$ is the weight assigned to interval $ j$ . Also, $ p(j)$ is the interval to the left of $ j$ that ends as close to the beginning of $ j$ as possible without overlapping. We’re assuming these were also computed beforehand.

The textbook I’m looking at says the runtime is $ O(n)$ because a single call to M-Compute-Opt is $ O(1)$ and we call it twice for every empty entry in array M. I almost buy it except it seems to me that we could end up calling it more often for some $ i \in \{1, \ldots , j\}$ if the function $ p$ maps lots of elements to that $ i$ . For example, if there is some interval $ i$ where right after it ends a ton of intervals start, $ p$ would map lots of intervals to it. And of course M-Compute-Opt wouldn’t be called from within those instances since the value would be stored the first time, but it seems they would run nonetheless.

I guess in general I understand the argument given in the book, but I was wondering if there is a good one way to understand the linear time from a more intuitive standpoint. I’m not used to calculating runtimes and I feel like if I saw a different problem like this one I wouldn’t come up with the “trick” used.

finding the parent index in an interval heap (stored on an array) given a child index

an interval heap is a binary tree stored on an array where the size of each node is 2.

i would like to be able to find the index of a parent and find one of the child indices given the index of a node.

an example of an interval trees indices would be:

         [0,1]      [2,3]     [4,5]  [6,7][8,9][10,11][12,13] 


         [1,2]      [3,4]     [5,6]  [7,8][9,10][11,12][13,14] 

Upper bound on the average number of overlaps for an interval within a set of intervals

Let $ \mathcal{I}$ be a set of intervals with cardinality $ L$ , where each interval $ I_i \in \mathcal{I}$ is of the form $ [a_i, b_i]$ and $ a_i, b_i$ are pairwise distinct non-negative integers bounded by a constant $ C$ i.e. $ 0 \leq a_i < b_i \leq C$ . We say a pair of intervals $ I_i, I_j \in \mathcal{I}$ overlap if the length of overlap is $ > 0$ .

Define a function $ F(i)$ which computes the number of intervals in $ \mathcal{I} \backslash I_i$ that interval $ I_i$ overlaps with. \begin{equation} F(i) = \sum_{j=1, j \neq i}^{L} Overlap(I_i, I_j) \end{equation} where the function $ Overlap(I_i, I_j)$ is an indicator function which returns 1 if $ I_i, I_j$ overlap, else it returns 0.

The average number of overlaps for the intervals in $ \mathcal{I}$ , denoted by $ Avg(\mathcal{I})$ is given by $ Avg(\mathcal{I}) = \dfrac{\sum_{i=1}^{L}F(i)}{L}$ .

The question is, suppose we are allowed to choose the intervals in the set $ \mathcal{I}$ with the following additional conditions:

  1. For any $ t \in [0, C]$ , we have at most $ M$ (and $ M < L$ ) intervals in $ \mathcal{I}$ such that $ t$ is contained within those $ M$ intervals. Stated differently, at most $ M$ intervals overlap at any point in time.
  2. Any interval in $ \mathcal{I}$ overlaps with at most $ K$ other intervals, and $ M < K < L$ .

then, what is an upper bound on $ Avg(\mathcal{I})$ for any choice of the intervals in $ \mathcal{I}$ satisfying 1, 2?

In case you are wondering, this problem is of interest to me in order to be able to study the run-time of a scheduling algorithm.

I am unable to come up with a non-trivial upper bound for $ Avg(\mathcal{I})$ and would be interested to know if the problem I stated has been studied. I am also open to ideas on how one may be able to obtain a tight upper bound for $ Avg(\mathcal{I})$ .

Coloring an interval graph with weights

I have an interval graph $ G=(V,E)$ and a set of colors $ C=\{c_1,c_2,…,c_m\}$ , when a color $ c_i$ is assigned to a vertex $ v_j$ , we have a score $ u_{ij}\geq 0$ . The objective is to find a coloring of $ G$ with at most $ m$ colors that maximizes the total score (sum of the scores of the vertices).

Do you know about any results in the literature that may help me to find the complexity of this problem?

Defining one variable function on specific interval and taking supremum of it

I got a course in my undergraduate education 4 years ago. So actually I can’t remember the details about mathematica. I’m trying to solve one thing about 1 week. Here is my question:

f is a continuos and bounded function on [a,b]. Define

blank”>{x,t\in[a,b]&space;and&space;|t-x|<\delta}|f(x)-f(t)|” title=”w(f,\delta)=sup_{x,t\in[a,b] and |t-x|<\delta}|f(x)-f(t)|” />

I want to write this function on mathematica and checking while delta going zero, is w will be going with it. I replaced supremum with MaxValue function. But I didn’t write when x,t in [a,b] take f(x)-f(t). Because f is a single variable and I dont know how can I put condition when t-x < delta.

These are my problems. After defining this function I want to see on graph how it changes with different delta’s