Skip to content

Instantly share code, notes, and snippets.

View cipher.sql
-- Tested on Postgres 9.2
create or replace temp view cipher as
select
'meetmebythetree'::varchar plain_text,
'scones'::varchar secret;
with
-- Recursively add 'secret' until result is longer than 'plain_text'
recursive secret_stream(repeated_secret) as (
View Cipher.scala
package cipher
import Function.tupled
object CipherTable {
// Key char -> Plain char -> Encoded char
val encodingTable = ('a' to 'z')
.map(col => col -> ('a' to 'z').zip((col to 'z') ++ ('a' until col)).toMap)
.toMap
View alphabet_cipher
open System
let resolveEncryptedLetter (letterToEncrypt:char, keywordLetter) =
let alphabet = "abcdefghijklmnopqrstuvwxyz"
alphabet.Split [| keywordLetter |]
|> Array.rev
|> Array.append [| keywordLetter |> string |]
|> Array.reduce (+)
|> Seq.toArray
|> fun rowOrderedByKeywordLetter