This isn’t oF-specific, but I think people here will have some insight.

Gray codes are an ordering of binary numbers that allow adjacent numbers to have only 1-bit of difference. For example, where n is the number of digits:

```
n = 3
000
001
011
010
110
111
101
100
```

(There’s a simple algorithm for generating these: http://en.wikipedia.org/wiki/Gray-codes#Constructing-an-n-bit-gray-code)

I’m looking for an ordering such that nearby codes have a large hamming-distance between each other. The closer codes are to each other, the bigger the distance should be.

I don’t know if there’s an optimal way to design this so that there’s a steady dropoff (e.g., i+1 distance is always n/2, i+2 is always n/3, i+2 is n/4, etc…), or if it’s more gaussian, or what. Or even if there is a regular way to do it.

One algorithm I’ve considered so far is iterating through Gray codes with an odd increment. E.g., stepping through n=4 in increments of 5 yields:

```
0000 3 4 1
0111 1 4 1
1111 3 2 1
1000 3 2 1
0110 3 4 1
1101 1 4 1
1001 3 2 1
0010 3 2 1
1100 3 4 1
1011 1 4 1
0011 3 2 1
0100 3 2 1
1010 3 4 1
0001 1 4 1
0101 3 2 1
1110 3 2 1
```

Which isn’t terrible, but it’s very irregular.

Any insight, comments, questions, etc. would be appreciated!