Skip to content

Instantly share code, notes, and snippets.

@trinker
Created February 3, 2019 22:22
Show Gist options
  • Save trinker/d35f5482d3db241cd3383a501fd4e4b5 to your computer and use it in GitHub Desktop.
Save trinker/d35f5482d3db241cd3383a501fd4e4b5 to your computer and use it in GitHub Desktop.
Secret Message
library(tidyverse)
map <- data_frame(
ins = c(LETTERS, letters),
outs = c(rev(LETTERS), rev(letters))
)
map
message <- 'Hello Norah,
I am writing in secret code. I am looking forward to when our family
will be coming over. The comercials for the Super Bowl game are the
best part of the game.
Love,
Daddy'
data_frame(
ins = strsplit(message, '')[[1]]
) %>%
left_join(map) %>%
mutate(outs = ifelse(is.na(outs), ins, outs)) %>%
summarize(out = paste(outs, collapse ='')) %>%
pull(out) %>%
cat()
message2 <- 'Svool Mlizs,
R zn dirgrmt rm hvxivg xlwv. R zn ollprmt ulidziw gl dsvm lfi uznrob
droo yv xlnrmt levi. Gsv xlnvixrzoh uli gsv Hfkvi Yldo tznv ziv gsv
yvhg kzig lu gsv tznv.
Olev,
Wzwwb'
data_frame(
outs = strsplit(message2, '')[[1]]
) %>%
left_join(map) %>%
mutate(ins = ifelse(is.na(ins), outs, ins)) %>%
summarize(ins = paste(ins, collapse ='')) %>%
pull(ins) %>%
cat()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment