In cryptarithmetic puzzles, mathematical equations are written using letters. Ea
ID: 3616863 • Letter: I
Question
In cryptarithmetic puzzles, mathematical equations are written using letters.
Each letter can be a digit from 0 to 9, but no two letters can be the same.
Customarily, distinct letters stand for
different digits
Here is a sample problem:
SEND + MORE = MONEY
A solution to the puzzle is S = 9, R = 8, O = 0, M = 1, Y = 2, E = 5, N = 6, D
= 7
S E N D
M O R E
+
------------
M O N E Y
That is,
9 5 6 7
1 0 8 5
+
------------
1 0 6 5 2
Write a program that finds solutions to the following cryptarithmetic puzzle:
TOO + TOO + TOO + TOO = GOOD
T O O
T O O
T O O
+
-----------
G O O D
The simplest technique is to use a nested loop for each unique letter (in this
case T, O, G, D). The loops would systematically assign the digits from 0-9 to
each letter. For example, it might first try T = 0, O = 0, G = 0, D = 0,
then T = 0, O = 0, G =0, D = 1, then T = 0, O = 0, G = 0, D = 2, etc. up to T
= 9, O = 9, G = 9, D = 9. In the loop body test that each variable is unique
and that the equation is satisfied. Output the values for the letters that
satisfy the equation.
Expected Output:
The values are: T = 1 O = 6 G = 0 D = 4
The values are: T = 4 O = 9 G = 1 D = 6
Explanation / Answer
please rate - thanks looks like your getting desperate--this is pure brute force #include using namespace std; int main() {int col[4],carry=0; int t,o,g,d,i; for(t=0;tRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.