Sha256: 3ad848cd07808c07ecec39afb355ef2d5277426725c8b977a8cfdeb18e6d1cd0

Contents?: true

Size: 559 Bytes

Versions: 220

Compression:

Stored size: 559 Bytes

Contents

function! AtbashDecode(cipher) abort
  return s:algorithm(s:normalize(a:cipher))
endfunction

function! AtbashEncode(plaintext) abort
  return s:chunk(AtbashDecode(a:plaintext))
endfunction

function! s:normalize(text) abort
  return substitute(tolower(a:text), '[^a-z0-9]', '', 'g')
endfunction

function! s:algorithm(text) abort
  let alphabet = 'abcdefghijklmnopqrstuvwxyz'
  let reversed = 'zyxwvutsrqponmlkjihgfedcba'
  return tr(a:text, alphabet, reversed)
endfunction

function! s:chunk(text) abort
  return join(split(a:text, '.\{5}\zs'))
endfunction

Version data entries

220 entries across 220 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.179 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.178 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.177 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.176 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.175 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.174 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.173 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.172 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.171 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.170 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.169 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.167 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.166 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.165 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.164 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.163 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.162 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.161 tracks/vimscript/exercises/atbash-cipher/example.vim
trackler-2.2.1.160 tracks/vimscript/exercises/atbash-cipher/example.vim