471,831 Members | 1,300 Online

# Cryptarithmetic Help

hey guys have got any idea of how to write a code for CRYPTARITHMETIC on --- PROJ + GOOD = EASY
Oct 4 '06 #1
3 3415
tyreld
144 100+
Your question makes no sense. You need to be more specific, and word it better. My impression is you are working on a project that needs decent crypto support that is fairly easy to implement.
Oct 4 '06 #2
Banfa
9,065 Expert Mod 8TB
I get the impression that he is trying to solve the alphametic puzzle

Expand|Select|Wrap|Line Numbers
1.  PROJ
2. +GOOD
3. -----
4.  EASY
5.
Which has multiple (100) solutions.

The brute force way is to assign digits to each letter in a loop and check the result to see if it is correct outputing correct results.
Oct 4 '06 #3
D_C
293 100+
Well there are 10 letters, ADEGJOPRSY, and I assume it's in decimal. Typically, each letter is unique. If it's in hexadecimal or a higher base, then it becomes much more difficult. You can think A has 10 possible values, D has 9 possible values, E has 8, and as a result there are 10! or 3628800 possibilities, assuming it's base 10 arithmetic.

There is some information though, for example G+P+carry = E <= 9, carry either being 0 or 1. As a result, G and P are not 9, possibly not 8. Each number is four letters/digits long, and I would focus on the carries. Each digit either has a carry or not a carry, and that gives 8 possibilities.

Take the least significant digits, D+J = Y. If there is no carry, then 0 < D,J < Y <= 9. D and J must be nonzero, otherwise D = Y or J = Y. That hinges on the uniqueness requirement. Also, 2*O = S. Otherwise, 0 <= Y < D,J <= 9 and O+O+1 = S.

If the problem is in decimal, then there must be at least one carry that causes a result to be zero. Also, it's probably easier to not consider each carry, because it may lead to duplicates. While you can prune some options, after that I would greedily select whichever number has the most possibilities (probably 5).
Oct 4 '06 #4