Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Gray-code/11l/gray-code.11l
Normal file
15
Task/Gray-code/11l/gray-code.11l
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
F gray_encode(n)
|
||||
R n (+) n >> 1
|
||||
|
||||
F gray_decode(=n)
|
||||
V m = n >> 1
|
||||
L m != 0
|
||||
n (+)= m
|
||||
m >>= 1
|
||||
R n
|
||||
|
||||
print(‘DEC, BIN => GRAY => DEC’)
|
||||
L(i) 32
|
||||
V gray = gray_encode(i)
|
||||
V dec = gray_decode(gray)
|
||||
print(‘ #2, #. => #. => #2’.format(i, bin(i).zfill(5), bin(gray).zfill(5), dec))
|
||||
Loading…
Add table
Add a link
Reference in a new issue