All posibilities question

Hi, i need for an project all posibilities of some numbers, rules are:
1)there's 3 diferent numbers: 0, 1, 2
2)the lenght must be of 5 characters (no more or less)
examples: (begin) 00000; 00001; 00012; 00102; 01002; ... 02210; .... 22222; (end)

I not ask for getting a c++ code, i just need all posibilities of those numbers.
I calculated on some sites and they said theres 127 posibilities or 156 or etc. (on different site's) and its duplicating a lot, i dont know how to get all the posibilities of those rules. Anyone know's how? Thanks in advance!

Sorry for my english tho.
Start with string 00000.

Loop
{
Output current string.
Look at far right value.
  If it's 0, change to to 1. Back to loop start.
  If it's 1, change it to 2. Back to loop start.
  If it's 2, change it to zero and look at next value along:
      If it's 0, change to to 1. Back to loop start.
      If it's 1, change it to 2. Back to loop start.
      If it's 2, change it to zero and look at next value along:
           If it's 0, change to to 1. Back to loop start.
           If it's 1, change it to 2. Back to loop start.
           If it's 2, change it to zero and look at next value along:
               If it's 0, change to to 1. Back to loop start.
               If it's 1, change it to 2. Back to loop start.
               If it's 2, change it to zero and look at next value along:
                   If it's 0, change to to 1. Back to loop start.
                   If it's 1, change it to 2. Back to loop start.
                   If it's 2, stop
}


This is counting. It's how you would count numbers up from zero. When you count up from 0, every time you get to 9, you increase the next digit by 1, and then go back to increasing the far right digit again. Like this:

...
07
08
09
What's next?
(0+1) (0 ) , which is 10
11
12
13
...
0999
What's next? Well, change the far-right 9 to a zero, and then increment the next number along. Oh, it's 9; change it to zero, increment the next number along. Oh, it's 9; change it to zero, increment the next number along...
1000

This is just counting up. That's all it is. But instead of going back to 0 after 9, you go back to 0 after 2.

000
001
002
What's next? The 2 becomes a zero, and we add one to the next digit.
010
011
012
What's next? The 2 becomes a zero, and we add one to the next digit.
020
021
022
What's next? The 2 becomes a zero, and we add one to the next digit. Oh, it already is two. So we make it zero and then add one to the next digit:
100
101
102
What's next? The 2 becomes a zero, and we add one to the next digit
110
111
112
...
Last edited on
I will try that, i will come back tomorow (its 10pm at my side) with an anwser
It's just counting. If you understand how counting up works, you know how this works.

Lots of people, I have found, do not actually understand how counting up works :)
Yes, it worked, thanks, i didnt need it as a program but it solved my problem, thanks anyways.
Topic archived. No new replies allowed.