Let $n\in\left[a;b\right]\cup[c;d],a<b<c<d$.
We know that $b-a=d-c=k$ and $c-b=l$.
Now, let $\bar{n}=\begin{cases}
n+k+l=n+d-c+c-b=n+d-b & \text{if }n\in\left[a;b\right]\\
n-k-l=n-d+c-c+b=n-d+b & \text{if }n\in\left[c;d\right]
\end{cases}$
From the definition of $n$, follows that if $n\in\left[a;b\right]\Longrightarrow\bar{n}\in\left[c;d\right]$ and if $n\in\left[c;d\right]\Longrightarrow\bar{n}\in\left[a;b\right]$.
That is, what $\bar{n}$ does is takes $n$ to the second interval if it's in the first, and vice versa. Here's an illustration:

I've been trying to obtain (guessing...) $\bar{n}$ in closed form but haven't succeeded and so, that's my question.
Where is this useful? If we let $a=65,b=90,c=97,d=122$, we can flip ASCII characters between uppercase and lowercase.
2026-04-09 00:22:37.1775694157