title: Does Gray code exist for other bases than two?
body: <p>Just a matter of curiosity, is the <a href="http://en.wikipedia.org/wiki/Gray_code" rel="noreferrer">Gray code</a> defined for bases other than base two?</p>
  
  <p>I tried to count in base 3, writing consecutive values paying attention to change only one <em>trit</em> at a time. I've been able to enumerate all the values up to 26 (3**3-1) and it seems to work.</p>
  
  <pre><code>        000              122              200
          001              121              201
          002              120              202
          012              110              212
          011              111              211
          010              112              210
          020              102              220
          021              101              221
          022              100              222
  </code></pre>
  
  <p>The only issue I can see, is that all three <em>trits</em> change when looping back to zero. But this is only true for odd bases. When using even bases looping back to zero would only change a single digit, as in binary.</p>
  
  <p>I even guess it can be extended to other bases, even decimal. This could lead to another ordering when counting in base ten ... :-)</p>
  
  <pre><code>    0  1  2  3  4  5  6  7  8  9 19 18 17 16 15 14 13 12 11 10
     20 21 22 23 24 25 26 27 28 29 39 38 37 36 35 34 33 32 31 30
  </code></pre>
  
  <p>Now the question, has anyone ever heard of it? Is there an application for it? Or it is just mathematical frenzy?</p>