Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Vigen-re-cipher/Julia/vigen-re-cipher.julia
Normal file
16
Task/Vigen-re-cipher/Julia/vigen-re-cipher.julia
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
→(a::Char, b::Char, ± = +) = 'A'+((a-'A')±(b-'A')+26)%26
|
||||
←(a::Char, b::Char) = →(a,b,-)
|
||||
|
||||
cleanup(str) = filter(a-> a in 'A':'Z', collect(uppercase.(str)))
|
||||
match_length(word, len) = repeat(word,len)[1:len]
|
||||
|
||||
function →(message::String, codeword::String, ↔ = →)
|
||||
plaintext = cleanup(message)
|
||||
key = match_length(cleanup(codeword),length(plaintext))
|
||||
return String(plaintext .↔ key)
|
||||
end
|
||||
←(message::String, codeword::String) = →(message,codeword,←)
|
||||
|
||||
cyphertext = "I want spearmint gum" → "Gimme!"
|
||||
println(cyphertext)
|
||||
println(cyphertext ← "Gimme!")
|
||||
Loading…
Add table
Add a link
Reference in a new issue