Skip to content

Instantly share code, notes, and snippets.

View volodymyr-korolyov's full-sized avatar

Volodymyr Korolyov volodymyr-korolyov

View GitHub Profile
-- 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 (
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
/**
* Straightforward Scala implementation
*/
object Postfix {
def main(args: Array[String]): Unit = {
println(eval("0 1 R"))
println(eval("0 0 R"))
println(eval("1 0 A 1 R N N"))
println(eval("0 0 A 0 N 0 N A R"))