Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
29
Task/Gray-code/Logo/gray-code-2.logo
Normal file
29
Task/Gray-code/Logo/gray-code-2.logo
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
to format :str :width [pad (char 32)]
|
||||
while [(count :str) < :width] [
|
||||
make "str word :pad :str
|
||||
]
|
||||
output :str
|
||||
end
|
||||
|
||||
; Output binary representation of a number
|
||||
to binary :number [:width 1]
|
||||
local "bits
|
||||
ifelse [:number = 0] [
|
||||
make "bits 0
|
||||
] [
|
||||
make "bits "
|
||||
while [:number > 0] [
|
||||
make "bits word (bitand :number 1) :bits
|
||||
make "number lshift :number -1
|
||||
]
|
||||
]
|
||||
output (format :bits :width 0)
|
||||
end
|
||||
|
||||
repeat 32 [
|
||||
make "num repcount - 1
|
||||
make "gray gray_encode :num
|
||||
make "decoded gray_decode :gray
|
||||
print (sentence (format :num 2) ": (binary :num 5) ": (binary :gray 5) ":
|
||||
(binary :decoded 5) ": (format :decoded 2)) ]
|
||||
bye
|
||||
Loading…
Add table
Add a link
Reference in a new issue