Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
9
Task/Gray-code/Erlang/gray-code-1.erl
Normal file
9
Task/Gray-code/Erlang/gray-code-1.erl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
-module(gray).
|
||||
-export([encode/1, decode/1]).
|
||||
|
||||
encode(N) -> N bxor (N bsr 1).
|
||||
|
||||
decode(G) -> decode(G,0).
|
||||
|
||||
decode(0,N) -> N;
|
||||
decode(G,N) -> decode(G bsr 1, G bxor N).
|
||||
Loading…
Add table
Add a link
Reference in a new issue