Created
February 3, 2019 22:22
-
-
Save trinker/d35f5482d3db241cd3383a501fd4e4b5 to your computer and use it in GitHub Desktop.
Secret Message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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