I have a bucket of elements, the amount of elements $E$ is given by this equation, with constraints on parameters $S_A$ and $S_B$:
$$ \begin{equation*} \left\{ \begin{alignedat}{3} E_0 = (4-S_{A}) + 4*N + S_{B} \\ S_{A} < 4 ; S_{A} \in N\\ S_{B} < 4 ; S_{B} \in N\\ S_A > S_B \end{alignedat} \right. \end{equation*} $$
I pick these elements 4 at a time, so that after $n$ times $E_n = E_0 - 4*n $ until I can't do it anymore because $E_{N} < 4$, after picking them N times.
How do I find an expression for the remaining elements $E_N$?
I know that the operation to do is the modulo one, but I can't come up with an expression:
$$ E_N = E_0 \mod 4 $$ $$ E_N = [ (4-S_{A}) + 4*N + S_{B}] \mod 4 $$ $$ E_N = ( 4 - S_A + S_B ) \mod 4 $$
And I can't simplify anymore. I would like to reach an expression that has not the modulo in it.
Is it possible?
Since I need to use it in code where calculating the modulo is not an option, I can create a lookup table which is doable because the $S_A,S_B$ are small values, however finding an expression would be beautiful.
LUT = lambda sa,sb:(4-sa+sb)%4
for sb in range(4):
for sa in range(4):
if(sa>sb):
print(f"f({sa},{sb}) -> {LUT(sa,sb)}")
f(1,0) -> 3
f(2,0) -> 2
f(3,0) -> 1
f(2,1) -> 3
f(3,1) -> 2
f(3,2) -> 3
Thanks a lot!
modin the expression)? Is it possible? – Fra93 Oct 12 '22 at 16:03