CSP Problem
CSP Problem
Solution
Variables : X = {C, R, O, S, A, N, D, G, E}.
Each variable has the domain {0, .., 9}.
We have the following constraints:
where C1 , .., C5 are the carry digits with domain {0, 1}.
Constraint (1):
We observe that R has to be even and S 6= 0. Moreover since S 6= 1 and R 6= 0, the
domain of R is DR = {4, 6, 8}. Thus the domain of S is DS = {2, 3, 4}. Therefore C1 = 0 .
Constraint (2):
Since 2 ≤ S ≤ 4, we have 3 ≤ S + 1 ≤ 5. Thus C2 = 0 and DE = {3, 4, 5}.
Constraint (3):
O + A = G + 10C3 .
Assume O = 0, so A = G + 10C3 . This is impossible whether C3 = 0 or C3 = 1 because
A 6= G and A ≤ 9. Thus O 6= 0.
Using a similar reasoning, we get A 6= 0.
2. S = 3, R = 6, E = 4, or
3. S = 4, R = 8, E = 5.
Let us explore these possibilities:
1
1. Assumption: S = 2, R = 4, E = 3.
From constraint (5), we get: C + 4 + C4 = A + 10 =⇒ C + C4 = A + 6. We have A ≥ 5,
thus C + C4 ≥ 11 which is impossible. Therefore S 6= 2, R 6= 4, E 6= 3 and we backtrack
to the previous step.
2. Assumption: S = 3, R = 6, E = 4.
From constraint (5), we get: C + 6 + C4 = A + 10 =⇒ C + C4 = A + 4. We
have A ≥ 2 =⇒ A + 4 ≥ 6. We also have C ≤ 9 =⇒ C + C4 ≤ 10. Thus
A + 4 ≤ 10 =⇒ A ≤ 6. Thus DA = {2, 5}.
2.1. Assumption: A = 2.
From constraint (5), we get: C + C4 = 6. Thus C = 5 and C4 = 1.
From constraint (3), we get: O+2 = G+10C3 . We know at this stage that DO = {7, 8, 9}.
D = 1, O = 2, S = 3, E = 4, A = 5, R = 6, G = 7, N = 8, C = 9
with C1 = C2 = C3 = C4 = 0 and C5 = 1.
We can verify that: 96233 + 62513 = 158746.