mike29892
mike29892

Reputation: 263

Strange Gray Code - Efficient Decoding

I am trying to figure out an efficient way to go from a strange Gray code to either Binary Reflected Gray Code or to normal binary.

The pattern goes:
000000
000001
000101
000100
000110
000111
010111
010110
010100
010101
010001
010000
010010
010011
011011
011010
011000
011001
001101
011100
011110
011111
1011111
1011110
1011100
1011101
and so on...

it uses up to 12 bits.

Upvotes: 0

Views: 477

Answers (2)

user613326
user613326

Reputation: 2180

Array string in [ "00001", "000011, ... etc.
Array string out [ "01" , "10" , ...

Loop through an array to find a match, use same index in other array for conversion.

Might also be nice to try conversion with a neural network; after a while it will convert it. Actually that's I think nice try, have you somewhere the full gray binary list?

Perhaps I like to give it a try in a yet to build neural network.

Upvotes: 0

MRAB
MRAB

Reputation: 20664

The most efficient method would be to use a dictionary/hash table. Alternatively, store them sorted in an array and use a binary search.

[EDIT]

Actually, now I think about it, a lookup table of 4096 entries wouldn't occupy that much space by today's standards.

Upvotes: 0

Related Questions