Can we show algebraically that this is true? This problem is part of a larger proof I've been working on. Long story short, I'm trying to prove a particular explicit formula for the recursive function
$$
t(p, 0) = 0 \\
t(p, k+1) = \left\lfloor \dfrac{t(p, k)}{3} \right\rfloor + p
$$
where $p=2n+1, n \in \mathbb{N}$. The inductive step of proving my particular explicit formula includes the following question:
Can we show algebraically that
$$ \left\lfloor \dfrac{1}{3} - \dfrac{1}{3} \left\lfloor \dfrac{2n-1}{2(3^{k-1})} + \dfrac{1}{2} \right\rfloor \right\rfloor \ \ = \ \ (-1) \left\lfloor \dfrac{2n-1}{2(3^k)} + \dfrac{1}{2} \right\rfloor$$
is true for all $k,n = 1, 2, 3, ...$ ? I used Python to test it and it seems to be true, at least for all $k≤1000, \ n≤1000$. Can anyone prove this rigorously? I tried using induction on $k$ but was not successful. I did not try induction on $n$.
Any help is appreciated.

Let $q = \dfrac{2n-1}{2\cdot 3^k}$, and so $\dfrac{2n-1}{2\cdot 3^{k-1}} = 3q$. Both $q$ and $3q$ are is always positive and never an integer for $k,n = 1,2,3, \ldots$.
Converting the RHS into an inequality,
$$\begin{array}{rcl}
\left(q+\dfrac12\right) -1 <& \left\lfloor q+\dfrac12\right\rfloor &\le q+\dfrac12\\
-q+\dfrac12 >& -\left\lfloor q+\dfrac12\right\rfloor &\ge -q-\dfrac12 
\end{array}$$
There is exactly one integer in this range.
From the LHS, consider the content inside the outer $\lfloor \ \rfloor$,
$$\begin{align*}
\frac13 - \frac13\left\lfloor 3q+\frac12\right\rfloor
&= -\frac13\left\lfloor-1+3q+\frac12\right\rfloor\\
&= -\frac13\left\lfloor3q-\frac12\right\rfloor
\end{align*}\\
\begin{array}{rcl}
\left(3q-\dfrac12\right)-1<& \left\lfloor3q-\dfrac12\right\rfloor &\le 3q-\dfrac12\\
-q+\dfrac12>& -\dfrac13\left\lfloor3q-\dfrac12\right\rfloor &\ge -q+\dfrac16\\
\end{array}$$
The middle $-\frac13\left\lfloor3q-\frac12\right\rfloor$ is a third of an integer. That means its floor satisfy a tighter inequality:
$$\begin{array}{rcl}
\left(-\dfrac13\left\lfloor3q-\dfrac12\right\rfloor\right) -\dfrac23 \le& \left\lfloor-\dfrac13\left\lfloor3q-\dfrac12\right\rfloor\right\rfloor &\le -\dfrac13\left\lfloor3q-\dfrac12\right\rfloor\\
\left(-q+\dfrac16\right) -\dfrac23 \le& \left\lfloor-\dfrac13\left\lfloor3q-\dfrac12\right\rfloor\right\rfloor &< -q+\dfrac12\\
-q -\dfrac12 \le& \left\lfloor-\dfrac13\left\lfloor3q-\dfrac12\right\rfloor\right\rfloor &< -q+\dfrac12\\
\end{array}$$
There is also exactly one integer in this range, and this matches the range of the RHS. So
$$LHS = \left\lfloor\frac13 - \frac13\left\lfloor \dfrac{2n-1}{2\cdot 3^{k-1}}+\frac12\right\rfloor\right\rfloor = -\left\lfloor \dfrac{2n-1}{2\cdot 3^k}+\frac12\right\rfloor = RHS.$$
