Hi, I'm trying to figure out how to do this assignment, but I don't even know where to begin.
This is a beginning project, all I know is arrays are not allowed. Can somebody get me started?

The assignment is..

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. Here is a sample problem:
A solution to the puzzle is S = 9, R = 8, O = 0, M = 1, Y = 2, E = 5, N = 6, D = 7
Write a program that finds solutions to the cryptarithmetic puzzle of:
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.

Member Avatar for iamthwee

Plan what you need on paper would be a good start?

just to test

You already have a plan. You have 4 variables T,O,D ,G and 10 possible number assignment. So the number of possibilities is : 10*9*8*7 = 5040 which is still small for computer. So you can solve it brutally if u want.

Try this if you get stuck:


using namespace std;

int main()

	int T,O,G,D;

for (T=0;T<=9;T++)

						if( (T==O)+(T==G)+(T==D)+(O==G)+(O==D)+(D==G)==0)	
						if(4*(100*T+10*O+O)==1000*G+100*O+10*O+D){ cout<<T<<O<<G<<D<<endl;};

return 0;
commented: Please don't use tabs to indent your code, use spaces! -2
Member Avatar for iamthwee

What is that supposed to show?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.