# Math puzzle with logic programming

I had below question in one of my assignments for Login Programming for Artificial Intelligence topic.

Solve the alphametic:

$$ABCDE$$
$$+$$ $$CFGH$$
-----------------
$$DEHIJ$$

where each letter A,..., J represents a different digit 0,...,9 and A>0, C>0, D>0, and A<6.

I have no idea how to solve this. So if anyone knows the answer, I would like to know how to solve this.

• no it is not my puzzle. It's one of the questions I have encountered. – Radiant Sep 4 '19 at 17:46
• I have no idea how to do it, so posted it over here – Radiant Sep 4 '19 at 17:48
• @RuchirNaphade , Where did you encounter the question, if you provide the source, I can add it in the question and your question will be unholded. – Quark-epoch Sep 4 '19 at 18:26
• Hi, and welcome to PSE! Unfortunately, this is not how this site works; you cannot just take someone else's puzzle, and post it here. Most of the questions here are the poster's own puzzles, but you can also post someone else's puzzle IF (and only if, for copyright reasons) you have permission to do so, OR if you clearly state the original author, which is enough as long as the puzzle is "kind of not really a literary work in itself". (As is the case here.) Happy puzzling! – Bass Sep 4 '19 at 18:28
• @Oray..Thanks for the link but I am not looking for answer only. I want to know how to solve this as this will be helpful for me to solve problems like this in future.. – Radiant Sep 9 '19 at 11:10

Given all the conditions, there is just one solution

$$(A,B,C,D,E,F,G,H,I,J) = (2,8,7,3,5,1,6,9,0,4)$$
that is
$$28735+7169 = 35904$$

Reasoning

If we add a $$4$$-digit number to a $$5$$-digit number, the starting digit of the result must be the same as or one more than the starting digit of the $$5$$-digit number. This means that $$D$$ is one more than $$A$$.
Since we have $$0, this means the possibilities for $$(A,D)$$ are $$(1,2), (2,3), (3,4), (4,5)$$ or $$(5,6)$$.

We also require that the last digit of $$E+H$$ be $$J$$. This leads us to the following ($$158$$) possibilities for $$(A,D,E,H,J)$$:
$$(1, 2, 3, 4, 7), (1, 2, 3, 5, 8), (1, 2, 3, 6, 9), (1, 2, 3, 7, 0), (1, 2, 4, 3, 7), (1, 2, 4, 5, 9), (1, 2, 4, 6, 0), (1, 2, 4, 9, 3), (1, 2, 5, 3, 8), (1, 2, 5, 4, 9), (1, 2, 5, 8, 3), (1, 2, 5, 9, 4), (1, 2, 6, 3, 9), (1, 2, 6, 4, 0), (1, 2, 6, 7, 3), (1, 2, 6, 8, 4), (1, 2, 6, 9, 5), (1, 2, 7, 3, 0), (1, 2, 7, 6, 3), (1, 2, 7, 8, 5), (1, 2, 7, 9, 6), (1, 2, 8, 5, 3), (1, 2, 8, 6, 4), (1, 2, 8, 7, 5), (1, 2, 8, 9, 7), (1, 2, 9, 4, 3), (1, 2, 9, 5, 4), (1, 2, 9, 6, 5), (1, 2, 9, 7, 6), (1, 2, 9, 8, 7), (2, 3, 1, 4, 5), (2, 3, 1, 5, 6), (2, 3, 1, 6, 7), (2, 3, 1, 7, 8), (2, 3, 1, 8, 9), (2, 3, 1, 9, 0), (2, 3, 4, 1, 5), (2, 3, 4, 5, 9), (2, 3, 4, 6, 0), (2, 3, 4, 7, 1), (2, 3, 5, 1, 6), (2, 3, 5, 4, 9), (2, 3, 5, 6, 1), (2, 3, 5, 9, 4), (2, 3, 6, 1, 7), (2, 3, 6, 4, 0), (2, 3, 6, 5, 1), (2, 3, 6, 8, 4), (2, 3, 6, 9, 5), (2, 3, 7, 1, 8), (2, 3, 7, 4, 1), (2, 3, 7, 8, 5), (2, 3, 7, 9, 6), (2, 3, 8, 1, 9), (2, 3, 8, 6, 4), (2, 3, 8, 7, 5), (2, 3, 8, 9, 7), (2, 3, 9, 1, 0), (2, 3, 9, 5, 4), (2, 3, 9, 6, 5), (2, 3, 9, 7, 6), (2, 3, 9, 8, 7), (3, 4, 1, 5, 6), (3, 4, 1, 6, 7), (3, 4, 1, 7, 8), (3, 4, 1, 8, 9), (3, 4, 1, 9, 0), (3, 4, 2, 5, 7), (3, 4, 2, 6, 8), (3, 4, 2, 7, 9), (3, 4, 2, 8, 0), (3, 4, 2, 9, 1), (3, 4, 5, 1, 6), (3, 4, 5, 2, 7), (3, 4, 5, 6, 1), (3, 4, 5, 7, 2), (3, 4, 6, 1, 7), (3, 4, 6, 2, 8), (3, 4, 6, 5, 1), (3, 4, 6, 9, 5), (3, 4, 7, 1, 8), (3, 4, 7, 2, 9), (3, 4, 7, 5, 2), (3, 4, 7, 8, 5), (3, 4, 7, 9, 6), (3, 4, 8, 1, 9), (3, 4, 8, 2, 0), (3, 4, 8, 7, 5), (3, 4, 8, 9, 7), (3, 4, 9, 1, 0), (3, 4, 9, 2, 1), (3, 4, 9, 6, 5), (3, 4, 9, 7, 6), (3, 4, 9, 8, 7), (4, 5, 1, 2, 3), (4, 5, 1, 6, 7), (4, 5, 1, 7, 8), (4, 5, 1, 8, 9), (4, 5, 1, 9, 0), (4, 5, 2, 1, 3), (4, 5, 2, 6, 8), (4, 5, 2, 7, 9), (4, 5, 2, 8, 0), (4, 5, 2, 9, 1), (4, 5, 3, 6, 9), (4, 5, 3, 7, 0), (4, 5, 3, 8, 1), (4, 5, 3, 9, 2), (4, 5, 6, 1, 7), (4, 5, 6, 2, 8), (4, 5, 6, 3, 9), (4, 5, 6, 7, 3), (4, 5, 7, 1, 8), (4, 5, 7, 2, 9), (4, 5, 7, 3, 0), (4, 5, 7, 6, 3), (4, 5, 7, 9, 6), (4, 5, 8, 1, 9), (4, 5, 8, 2, 0), (4, 5, 8, 3, 1), (4, 5, 8, 9, 7), (4, 5, 9, 1, 0), (4, 5, 9, 2, 1), (4, 5, 9, 3, 2), (4, 5, 9, 7, 6), (4, 5, 9, 8, 7), (5, 6, 1, 6, 7), (5, 6, 1, 7, 8), (5, 6, 1, 8, 9), (5, 6, 1, 9, 0), (5, 6, 2, 4, 6), (5, 6, 2, 6, 8), (5, 6, 2, 7, 9), (5, 6, 2, 8, 0), (5, 6, 2, 9, 1), (5, 6, 3, 1, 4), (5, 6, 3, 4, 7), (5, 6, 3, 6, 9), (5, 6, 3, 7, 0), (5, 6, 3, 8, 1), (5, 6, 3, 9, 2), (5, 6, 4, 2, 6), (5, 6, 4, 6, 0), (5, 6, 4, 7, 1), (5, 6, 4, 8, 2), (5, 6, 7, 1, 8), (5, 6, 7, 2, 9), (5, 6, 7, 4, 1), (5, 6, 7, 9, 6), (5, 6, 8, 1, 9), (5, 6, 8, 2, 0), (5, 6, 8, 4, 2), (5, 6, 8, 6, 4), (5, 6, 8, 9, 7), (5, 6, 9, 1, 0), (5, 6, 9, 2, 1), (5, 6, 9, 7, 6), (5, 6, 9, 8, 7)$$

Then, it must be the case that $$D+G$$ plus the carry-over term from $$E+H$$ must end in $$I$$. This leaves the number of possibilities for $$(A,D,E,H,J,G,I)$$ at $$324$$:
$$(1, 2, 3, 4, 7, 6, 8), (1, 2, 3, 4, 7, 8, 0), (1, 2, 3, 5, 8, 4, 6), (1, 2, 3, 5, 8, 7, 9), (1, 2, 3, 6, 9, 5, 7), (1, 2, 3, 6, 9, 8, 0), (1, 2, 3, 7, 0, 5, 8), (1, 2, 3, 7, 0, 6, 9), (1, 2, 4, 3, 7, 6, 8), (1, 2, 4, 3, 7, 8, 0), (1, 2, 4, 5, 9, 6, 8), (1, 2, 4, 5, 9, 8, 0), (1, 2, 4, 6, 0, 5, 8), (1, 2, 4, 9, 3, 5, 8), (1, 2, 4, 9, 3, 7, 0), (1, 2, 5, 3, 8, 4, 6), (1, 2, 5, 3, 8, 7, 9), (1, 2, 5, 4, 9, 6, 8), (1, 2, 5, 4, 9, 8, 0), (1, 2, 5, 8, 3, 4, 7), (1, 2, 5, 8, 3, 6, 9), (1, 2, 5, 8, 3, 7, 0), (1, 2, 5, 9, 4, 0, 3), (1, 2, 5, 9, 4, 3, 6), (1, 2, 5, 9, 4, 7, 0), (1, 2, 6, 3, 9, 5, 7), (1, 2, 6, 3, 9, 8, 0), (1, 2, 6, 4, 0, 5, 8), (1, 2, 6, 7, 3, 5, 8), (1, 2, 6, 8, 4, 0, 3), (1, 2, 6, 8, 4, 7, 0), (1, 2, 6, 9, 5, 0, 3), (1, 2, 6, 9, 5, 4, 7), (1, 2, 6, 9, 5, 7, 0), (1, 2, 7, 3, 0, 5, 8), (1, 2, 7, 3, 0, 6, 9), (1, 2, 7, 6, 3, 5, 8), (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 4), (5, 6, 3, 9, 2, 0, 7), (5, 6, 3, 9, 2, 1, 8), (5, 6, 3, 9, 2, 4, 1), (5, 6, 3, 9, 2, 7, 4), (5, 6, 4, 3, 7, 2, 8), (5, 6, 4, 7, 1, 2, 9), (5, 6, 4, 7, 1, 3, 0), (5, 6, 4, 8, 2, 0, 7), (5, 6, 4, 8, 2, 3, 0), (5, 6, 4, 9, 3, 0, 7), (5, 6, 4, 9, 3, 1, 8), (5, 6, 7, 1, 8, 3, 9), (5, 6, 7, 1, 8, 4, 0), (5, 6, 7, 2, 9, 4, 0), (5, 6, 7, 2, 9, 8, 4), (5, 6, 7, 3, 0, 1, 8), (5, 6, 7, 3, 0, 2, 9), (5, 6, 7, 3, 0, 4, 1), (5, 6, 7, 4, 1, 2, 9), (5, 6, 7, 4, 1, 3, 0), (5, 6, 8, 1, 9, 4, 0), (5, 6, 8, 1, 9, 7, 3), (5, 6, 8, 2, 0, 4, 1), (5, 6, 8, 2, 0, 7, 4), (5, 6, 8, 3, 1, 0, 7), (5, 6, 8, 3, 1, 2, 9), (5, 6, 8, 3, 1, 7, 4), (5, 6, 8, 4, 2, 0, 7), (5, 6, 8, 4, 2, 3, 0), (5, 6, 8, 9, 7, 3, 0), (5, 6, 8, 9, 7, 4, 1), (5, 6, 9, 1, 0, 7, 4), (5, 6, 9, 2, 1, 0, 7), (5, 6, 9, 2, 1, 3, 0), (5, 6, 9, 2, 1, 7, 4), (5, 6, 9, 3, 2, 0, 7), (5, 6, 9, 3, 2, 1, 8), (5, 6, 9, 3, 2, 4, 1), (5, 6, 9, 3, 2, 7, 4), (5, 6, 9, 4, 3, 0, 7), (5, 6, 9, 4, 3, 1, 8), (5, 6, 9, 8, 7, 3, 0), (5, 6, 9, 8, 7, 4, 1)$$

Now, if we impose the condition that $$C+F$$ plus the carry over term from the tens ends in $$H$$, only some of these cases can be made to work and the number of possibilities for $$(A,D,E,H,J,G,I,C,F)$$ reduces to $$159$$:
$$(1, 2, 3, 4, 7, 6, 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, 0, 7, 4, 8, 2), (5, 6, 9, 2, 1, 0, 7, 4, 8), (5, 6, 9, 2, 1, 0, 7, 8, 4), (5, 6, 9, 2, 1, 3, 0, 4, 7), (5, 6, 9, 2, 1, 3, 0, 7, 4), (5, 6, 9, 2, 1, 7, 4, 3, 8), (5, 6, 9, 2, 1, 7, 4, 8, 3)$$

Notice here that the remaining unused digit will be assigned to $$B$$ so we can try out the sum in each of these $$159$$ cases to see if it will work.
Only one of these (46th in the list) actually produces a valid solution.

• That seems awfully brute-forcey ... – Rand al'Thor Sep 12 '19 at 15:50
• @Randal'Thor Yep, I tried a couple of different approaches but they seemed to all reduce to more than 100 cases to check. For example, it's very easy to deduce that either F,G,I or J must be zero but even ruling out the case J=0 is a pain. – hexomino Sep 12 '19 at 16:01
• @hexomino...Thanks a lot for explaining – Radiant Sep 12 '19 at 16:05
• I guess the OP did say it's for a programming challenge, not a maths one. – Rand al'Thor Sep 12 '19 at 16:14
• Seems like a pretty anti-climactic question/answer for PSE then. – Somebody Sep 12 '19 at 16:20