Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Substitution-cipher/Wren/substitution-cipher.wren
Normal file
18
Task/Substitution-cipher/Wren/substitution-cipher.wren
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
var key = "]kYV}(!7P$n5_0i R:?jOWtF/=-pe'AD&@r6\%ZXs\"v*N[#wSl9zq2^+g;LoB`aGh{3.HIu4fbK)mU8|dMET><,Qc\\C1yxJ"
|
||||
|
||||
var encode = Fn.new { |s|
|
||||
var res = ""
|
||||
for (c in s) res = res + key[c.bytes[0] - 32]
|
||||
return res
|
||||
}
|
||||
|
||||
var decode = Fn.new { |s|
|
||||
var res = ""
|
||||
for (c in s) res = res + String.fromByte(key.indexOf(c) + 32)
|
||||
return res
|
||||
}
|
||||
|
||||
var s = "The quick brown fox jumps over the lazy dog, who barks VERY loudly!"
|
||||
var enc = encode.call(s)
|
||||
System.print("Encoded: %(enc)")
|
||||
System.print("Decoded: %(decode.call(enc))")
|
||||
Loading…
Add table
Add a link
Reference in a new issue