0% found this document useful (0 votes)
67 views

CSP Problem

The document summarizes the solution steps to a cryptarithmetic puzzle involving the letters CROSS + ROADS = DANGER. It begins by defining variables and constraints. It then systematically tests different assignments for the variables S, R, and E, and explores the implications of each to arrive at a unique solution: D=1, O=2, S=3, E=4, A=5, R=6, G=7, N=8, C=9.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

CSP Problem

The document summarizes the solution steps to a cryptarithmetic puzzle involving the letters CROSS + ROADS = DANGER. It begins by defining variables and constraints. It then systematically tests different assignments for the variables S, R, and E, and explores the implications of each to arrive at a unique solution: D=1, O=2, S=3, E=4, A=5, R=6, G=7, N=8, C=9.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

A cryptarithmetic problem

Consider the following cryptarithmetic puzzle:


CROSS + ROADS = DANGER

Solution
Variables : X = {C, R, O, S, A, N, D, G, E}.
Each variable has the domain {0, .., 9}.
We have the following constraints:

S+S = R + 10C1 (1)


S + D + C1 = E + 10C2 (2)
O + A + C2 = G + 10C3 (3)
R + O + C3 = N + 10C4 (4)
C + R + C4 = A + 10C5 (5)
D = C5 (6)
C 6= 0 (7)
R 6= 0 (8)
D 6= 0 (9)
Alldif f (C, R, O, S, A, N, D, G, E) (10)

where C1 , .., C5 are the carry digits with domain {0, 1}.

Constraints (6) and (9):


C5 = D = 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.

At this stage, we have the following possible values for S, R and E:


1. S = 2, R = 4, E = 3, or

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}.

• If C3 = 0, then O = 7, G = 9. From constraint (4), we get: 6 + 7 = N + 10.


Impossible because N 6= 3.

• If C3 = 1, then O = 8, G = 0. From constraint (4), we get: 6 + 8 + 1 = N + 10.


Impossible because N 6= 5.

Therefore our assumption about A cannot be true and we conclude that A = 5.

2.2. Assumption: A = 5. From constraint (3), we get: O + 5 = G + 10C3 . At


this stage, DO = {2, 7, 8, 9} and DG = {0, 2, 7, 8, 9}.

• If C3 = 0, then O + 5 = G, thus O = 2 and G = 7.


From constraint (4), we get: 6 + 2 = N + 10C4 . Thus N = 8 and C4 = 0.
From constraint (5), we get: C + 6 = 15 =⇒ C = 9. We have found an assignment
to all variables at this stage. Since there is a unique solution to the puzzle, we do
not need to explore further.

The solution to the puzzle is as follows:

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.

You might also like