human
I found an interesting problem on https://www.codewars.com/kata/5416ce834c2460b4d300042d:
Gray code is a form of binary encoding where transitions between consecutive numbers differ by only one bit. This is a useful encoding for reducing hardware data hazards with values that change rapidly and/or connect to slower hardware as inputs. It is also useful for generating inputs for Karnaugh maps.

Here is an exemple of what the code look like:

```
0:    0000
1:    0001
2:    0011
3:    0010
4:    0110
5:    0111
6:    0101
7:    0100
8:    1100
```

The goal of this kata is to build two function bin2gray and gray2bin wich will convert natural binary to Gray Code and vice-versa. We will use the "binary reflected Gray code". The input and output will be arrays of 0 and 1, MSB at index 0.

There are "simple" formula to implement these functions. It is a very interesting exercise to find them by yourself.

All input will be correct binary arrays.

I tried it in Python, but could not do it. Can you solve it?
assistant
#Here is Python program to find them by yourself.

def bitlist(func):
    def wrapper(bits):
        i = int(''.join([str(b) for b in bits]), 2)
        result = func(i)
        return [int(b) for b in bin(result)[2:]]
    return wrapper

@bitlist
def bin2gray(bits):
    return bits >> 1 ^ bits

@bitlist
def gray2bin(bits):
    mask = bits >> 1
    while(mask != 0):
         bits ^= mask
         mask >>= 1
    return bits