Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
symbolTable: @`a`..`z`
|
||||
|
||||
encodeWord: function [s][
|
||||
symt: new symbolTable
|
||||
result: []
|
||||
loop s 'c [
|
||||
idx: index symt c
|
||||
'result ++ idx
|
||||
symt: (rotate symt\[0..idx] 1) ++ symt\[(idx+1)..dec size symt]
|
||||
]
|
||||
return result
|
||||
]
|
||||
|
||||
decodeWord: function [s][
|
||||
symt: new symbolTable
|
||||
result: []
|
||||
loop s 'idx [
|
||||
'result ++ symt\[idx]
|
||||
symt: (rotate symt\[0..idx] 1) ++ symt\[(idx+1)..dec size symt]
|
||||
]
|
||||
return join result
|
||||
]
|
||||
|
||||
loop ["broood", "babanaaa", "hiphophiphop"] 'word [
|
||||
encoded: encodeWord word
|
||||
decoded: decodeWord encoded
|
||||
print ["'"++word++"'" "encodes to" encoded "which correctly decodes to" "'"++decoded++"'"]
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue