The only letter here that was changed here was the one representing 8
Does anyone have any ideas on how I can go about solving this problem?
10-20-2005, 08:48 PM
One way would be to have an number of nested loops that iterate thru the 3 possible letters for each number. That would be an easy solution for a fixed number of digits in the number.
For a variable/not fixed number of digits, that will take some thought.
10-20-2005, 09:59 PM
I believe it will be for a set number of digits. I know I have to use nested loops, but I am not able to picture how they would work.
I know it would go throught the digits one at a time, and there would be three iterations for each digit, but doesen't there have to be another loop? That is what I don't know how to do
You want to create all possible combinations. Use base 3 indexes. You want the indexes to run from: 00...0 thru 22...2 base 3.
For example: 00000, 00001, 00002, 00010 etc
Use each digit as an index: ie 0,0,0,0,0 to 0,0,0,1,0 to the above arrays.
One way to generate this series is to count with an int and then convert it to base 3.
To convert an int base 10 to base 3, modulo and divide by 3 and modulo.
For example 26 base 10 = 222 base 3. 26%3 = 2; 26/3 % 3 = 2; 26/9 %3 = 2