(The way that I think the) Problem: Given a increasing finite sequence $\{a_n\}_{n=1}^d$ of $d$ real numbers and positive real numbers $l$ and $k$, find $p$ and $q$ such that the sequence $\{b_n\}_{n=0}^\infty=\{pn+q\}$ has the property:
$$(a_i-l,a_i+l)\bigcap(b_j-k,b_j+k)=\emptyset\quad \forall i,j.$$$$(a_i-l,a_i+l)\cap(b_j-k,b_j+k)=\emptyset\quad \forall i,j.$$
That is: we have open intervals around each $a_i$ with size $2l$ and we must find $p$ and $q$ such that the intervals with size $2k$ around numbers of the form $\{pn+q\}$ has no intersection with the first ones.
My attempt to solve the problem: The problem looks like an optimization problem, so I tried to define a function $F(p,q)$ such the solutions correspond to the minimum of this function. One option is: $$F(p,q)=\int_{\mathbb{R}}f(x)g(x)dx,$$$$F(p,q)=\int_{\mathbb{R}}f(x)g(x)\,dx,$$
where $$f(x) =
\begin{cases}
1, & \text{if $x \in (a_i-l,a_i+l)$ } \\
0, & \text{if $x \notin (a_i-l,a_i+l)$ }
\end{cases}$$
and
$$g(x) =
\begin{cases}
1, & \text{if $x \in (b_i-k,b_i+k)$ } \\
0, & \text{if $x \notin (b_i-k,b_i+k)$ }
\end{cases}.$$
Certainty $F(p,q)\ge0$ $\forall p,q$. Also $F(p,q)=0$ is a solution to the problem. As $f(x)\neq0$ only for a finite number of finite intervals this becomes
$$F(p,q)=\sum_{n=0}^d\int_{a_n-l}^{a_n+l}g(x)dx.$$$$F(p,q)=\sum_{n=0}^d\int_{a_n-l}^{a_n+l}g(x)\,dx.$$
That $g(x)$ can be written as a Heaviside function applied to a cosine function:
$$g(x)=H\left(\cos\left(\frac{2\pi}{p}x-\frac{2\pi}{p}q\right)-\cos\left(\frac{2\pi k}{p}\right)\right).$$
So we have
$$F(p,q)=\sum_{n=0}^d\int_{a_n-l}^{a_n+l}H\left(\cos\left(\frac{2\pi}{p}x-\frac{2\pi}{p}q\right)-\cos\left(\frac{2\pi k}{p}\right)\right)dx.$$$$F(p,q)=\sum_{n=0}^d\int_{a_n-l}^{a_n+l}H\left(\cos\left(\frac{2\pi}{p}x-\frac{2\pi}{p}q\right)-\cos\left(\frac{2\pi k}{p}\right)\right) \, dx.$$