______          __          ______          
  / ____/___  ____/ /__  _____/ ____/_  ______ 
 / /   / __ \/ __  / _ \/ ___/ /   / / / / __ \
/ /___/ /_/ / /_/ /  __/ /  / /___/ /_/ / /_/ /
\____/\____/\__,_/\___/_/   \____/\__,_/ .___/ 
                                      /_/ 
        

$1,500 in prize money and unique problems. Register for the TrialSpark x Coder Cup competition by Feburary 22 before space runs out. Also, TrialSpark is hiring engineers.

Coder Cup Interview Challenge: Gray Code Conversion

The winner of this competition earns $500. Those who are interested and provide a code snippet are eligible for interview fast-tracks into the the Coder Cup software engineering position (full-time contractor position at an hourly rate of $80-$100). Submissions for prize money are now closed.

Edited Feb 10 04:10:22 2020 UTC

Gray code, named after Frank Gray, is a binary numeral system where two successive values differ in only one bit. The reflected binary code was originally designed to prevent spurious output from electromechanical switches. Conversion between binary to gray code happens like so:

Binary Gray
0000 0000
0001 0001
0010 0011
0011 0010
0100 0110
0101 0111
0110 0101
0111 0100
1000 1100
1001 1101
1010 1111
1011 1110
1100 1010
1101 1011
1110 1001
1111 1000


The goal of this challenge is to write a function that takes in some decimal value, converts it to a binary value (matching endianness as seen in the above table), and then converts this binary value to its gray code equivalent. We will be measuring winners based on creativity and correctness. Bonus points go to those who avoid usage of a table (while in practice, such a table would probably be used, it is less interesting of a solution).

As output for the results of this form, input the number 187836561118445077 converted into its Gray Code equivalent.