Original Post
Ok, here''s what''s up. I am just learning C++, but I learn by going ahead of myself. So here''s what I have, and the idea I have to solve it.
Have you ever seen a problem like this:
she
x he
______
haho
The idea of this is to change each letter into a number, so you have an actual equation that really works. You could take any equation, assign each number a letter, and give the letters out. Say you have:
2456
+465
_____
2921
you could assign each number a letter:
2=a
4=b
5=c
6=d
9=e
1=f
We would then turn out:
abcd
+bdc
_____
aeaf
Now you should have an idea as to the problem, because in this case we do NOT know that A is 2 etc.. All we know is:
abcd
+bdc
______
aeaf
Well, I would like to make a program that solves this.
I have come up with a way to do this, but the people I have asked I have not been able to explain this to properly.
First we are asked in input the first line:
abcd
Then the operation:
+
then the second line:
bdc
And finnally the product:
aeaf
(Of course, the following is in a loop)
The program would now have to find that in this certain equation we have a, b, c, d, e and f.
Finnally we need to assign a number to each number, and then run it to see if this is the proper set of numbers.
If it isnt, we then need to change ONE letter, then run the program again, so we then test every single possible combination.
So it would start with say:
a= 1
b= 2
c= 3
d= 4
e= 5
f= 6
And then run the operation:
1234
+243
______
1516
Now it needs to check if this operation works, probably by checking the result of 1234 + 243 with the product 1516.
It would the find that that is not correct.
So we add one number onto the last letter.
a= 1
b= 2
c= 3
d= 4
e= 5
f= 7 (We change this one)
Then try it again.
And continue this, only after running from 7-0 (we cannot use 1-5, as they are already taken by other numbers) on the letter f, we move on to other letters. At this point it comes to my attention that in this is missing something, as we have not checked f with the other numbers.
I believe the solution for this is we now must change e to 6, leaving the numbers 5, 8, 9, and 0 for f.
I believe a good way to simplify this is by making all the letters into a certain number.
Say we start with:
1 2 3 4 5 6
a b c d e f
Our number is 123456.
At the end of the loop, if the equation is not correct, we add 1 to the number.
123457
and so on.
We would then also have to build in somehow something to make sure the same number is not there twice, but this is not neccesary.
This about concludes what I can think of.
I thank you for reading this, and if you don''t get a certain part I will change that if you post with what you dont get.
Thanks!