# Linear equation with integer digits solution

I’m new to Julia and I want tot solve this problem with integer, digits solutions:
“Each letter represents a different non-zero digit: SEE + SEE = AXES”

I create this code and returns an inaccurate solution:

``````using JuMP, Clp

m = Model(Clp.Optimizer)

@variables m begin
A
X
E
S
end

#SEE + SEE = AXES
@constraints m begin
2(100S + 10E + E) == 1000A + 100X + 10E + S
A >= 1; A <=9
X >= 1; X <=9
E >= 1; E <=9
S >= 1; S <=9
end

optimize!(m)

value.((A, X, E, S))
``````

I can’t force proper the constrains. Any help is wellcomed!

Do you have to use Clp? If not, this works:

``````using JuMP, GLPK

m = Model(GLPK.Optimizer)

@variables m begin
A, Int
X, Int
E, Int
S, Int
end

#SEE + SEE = AXES
@constraints m begin
2(100S + 10E + E) == 1000A + 100X + 10E + S
A >= 1; A <=9
X >= 1; X <=9
E >= 1; E <=9;
S >= 1; S <=9;
end

optimize!(m)
``````
4 Likes

TYVM!

I don’t need any particular solver just to compare the code with Python and Sagemath. Julia beats them hands down!

You are welcome. I am by no means an expert in this field, and cannot comment whether this is the best solution.
The difference from you formulation ist, that the integer constraint is given in the variable definition.
If you are interested the corresponding part in the docs can be found here:
https://jump.dev/JuMP.jl/dev/manual/variables/#Integer-constraints