# Subtraction square dance alphametic

Every letter stands for a digit in base-10 representation, different letters stand for different digits, and leading digits are always non-zero.

      SQUARE
-  DANCE
------------
DANCER


This square dance alphametic has a unique solution under the addition and a unique solution under the subtraction. This makes the square dance alphametic special and interesting.

Which digit does each letter represent? (Please present the full analysis how these digits can be determined.)

There is a single valid solution which is

$R=0, E=8, C=2, A=7, N=4, S=6, D=5$ and $Q=3$

Proof

Clearly, from the units part of equation
$R= E-E =0$
and from the $10$s
$C \equiv - E (\text{mod } 10)$.
Also, as before, we can take advantage of the fact that $D=S-1$ so that we must have a pair of consecutive digits at the end of calculation (provided we proceed from right to left as below).

As with the previous alphametic, if we select $E$ the rest is determined to a large extent. This time, I'll go through each of the cases explicitly.

$E=1 \rightarrow C=9$ and since $A-N-1 \equiv 9 (\text{mod } 10)$ we get $A \equiv N (\text{mod } 10)$ which is not allowed.

$E=2 \rightarrow C=8$ which means $A-N-1 \equiv 8(\text{mod } 10)$ and $A = N-1$. Then, $U-A-1 \equiv N (\text{mod } 10) \rightarrow U=2N(\text{mod }10)$.
Since $0$, $2$ and $8$ are taken, this means that $U=4$ or $6$ but $U=6$ isn't feasible since then $N=3$ (since it can't be $8$) and $A=2$ (already taken). Hence, $U=4 \rightarrow N=7 \rightarrow A=6$. But this solution fails to preserve a pair of consecutive digits for $D$ and $S$.

$E=3 \rightarrow C=7 \rightarrow A-N-1 \equiv 7 (\text{mod } 10)$. Now, we could have $(A,N) = (9,1)$ or $A=N-2$. If the former, then $U=2$ and $Q \equiv D (\text{mod }10)$ which is not allowed.
If the latter then $U-A-1 \equiv N (\text{mod } 10) \rightarrow U \equiv 2N-1(\text{mod }10)$ which mean that $U$ must be $1, 5$ or $9$. We divide this into subcases
(i) $U=1 \rightarrow N=6 \rightarrow A=4 \rightarrow S=9$ and $D=8$ (since they are the only remaining consecutive digits). But then $Q-9 \equiv 4 (\text{mod }10) \rightarrow Q=E=3$ which is not allowed.
(ii) $U=5 \rightarrow N=8 \rightarrow A=6 \rightarrow S=2, D=1$ but then $Q-2 = 6 \rightarrow Q=N=8$ also not allowed
(iii) $U=9 \rightarrow N=5 \rightarrow A=E=3$ which is not allowed.

$E=4 \rightarrow C=6 \rightarrow A-N-1 \equiv 6 (\text{mod }10)$. So $(A,N) = (9,2), (8,1), (2,5)$ or $(5,8)$
(i) $A=9 \rightarrow U=1 \rightarrow Q=D$ which is not allowed.
(ii) $A=8 \rightarrow U=9 \rightarrow S=3, D=2 \rightarrow Q-2 \equiv 8 (\text{mod } 10) \rightarrow Q=R=0$ not allowed.
(iii) $A=2 \rightarrow U=8$ which means there are no consecutive digits left for $S$ and $D$.
(iv) $A=5 \rightarrow U=4=E$, not allowed.

$E=5 \rightarrow C=5$, not allowed.

$E=6 \rightarrow C=4 \rightarrow (A,N) = (2,7), (3,8), (7,2)$ or $(8,3)$ then
(i) $A=2 \rightarrow U=0=R$, not allowed
(ii) $A=3 \rightarrow U=2$ but there are no remaining consecutive digits for $S$ and $D$.
(iii) $A=7 \rightarrow U=9$ but again no remaining consecutive digits for $S$ and $D$.
(iv) $A=8 \rightarrow U=1 \rightarrow S=3, D=2 \rightarrow Q=1=U$, not allowed.

$E=7 \rightarrow C=3 \rightarrow (A,N) = (2,8), (5,1), (6,2), (8,4) or (9,5)$ then
(i) $A=2 \rightarrow U=1 \rightarrow D=4,5$ and $Q-D=3$ which means $Q=7$ or $8$ so $Q=E$ or $Q=N$, both of which are not allowed.
(ii) $A=5 \rightarrow U=6 \rightarrow S=9, D=8$ but then $Q=3=C$, not allowed.
(iii) $A=6 \rightarrow U=8 \rightarrow S=5, D=4$ but then $Q=0=R$, not allowed
(iv) $A=8 \rightarrow U=2 \rightarrow S=6, D=5$ but then $Q=4=N$, not allowed.
(v) $A=9 \rightarrow U=4 \rightarrow S=2, D=1 \rightarrow Q=1=D$, not allowed.

$E=8 \rightarrow C=2 \rightarrow (A,N) = (2,9), (4,1), (6,3), (7,4)$ or $(9,6)$ then
(i)$A=2 \rightarrow U=2=A$, not allowed
(ii) $A=4 \rightarrow U=5 \rightarrow S=7, D=6 \rightarrow Q=0=R$, not allowed
(iii) $A=6 \rightarrow U=9 \rightarrow S=5, D=4 \rightarrow Q=0=R$, not allowed
(iv) $A=7 \rightarrow U=1 \rightarrow S=6, D=5 \rightarrow Q=3$ which is a valid solution
(v) $A=9 \rightarrow U=5 \rightarrow S=4, D=3 \rightarrow Q=3=D$, not allowed.

Finally $E=9 \rightarrow C=1 \rightarrow (A,N) = (4,2), (5,3), (6,4), (7,5)$ or $(8,6)$ then
(i) $A=4 \rightarrow U=6 \rightarrow S=8, D=7$ but then $Q=1=C$, not allowed.
(ii) $A=5 \rightarrow U=8 \rightarrow S=7, D=6 \rightarrow Q=1=C$, not allowed
(iii) $A=6 \rightarrow U=0=R$, not allowed.
(iv) $A=7 \rightarrow U=2 \rightarrow S=4, D=3 \rightarrow Q=0=R$, not allowed.
(v) $A=8 \rightarrow U=4 \rightarrow S=3, D=2 \rightarrow Q=1=C$, not allowed.