最近几日,一则关于Google在MIT寻找变态大牛的消息登上各大blog、twitter的头版头条,Google的这则消息说如果谁破解了此中密码,将从此风花雪月,歌舞升平。我也乘机依循线索试图旁观一翻,幸亏我还算是个明白人,打眼一看就知道我跟天上人间的浪漫生活无缘了。
今天,会E文的,会R文的牛孙们已经张贴破解答案出来,语言虽然不懂,破解的版本还是一致的,但是牛头已经无幸瞻仰了。
我想虽然不懂,但也不能就这样不跟富足的生活扯上点关系。所以搬出R来,照葫芦画瓢把Google编码的原理折腾了一翻。如果还有类似的以后,就拿这个出来吃香的喝辣的啦!Code
CodeTrans <- function(key.word="JOBS"){
word.num <- nchar(key.word)
code.cut <- code.ini[-(1:word.num)]
word.pos <- grep(paste(strsplit(key.word,"")[[1]],sep="",collapse="|"),code.ini)
word.no <- match(strsplit(key.word,"")[[1]],code.ini)
key.num <- as.character(0:(word.num-1))
names(key.num) <- paste(word.no)
key.num <- key.num[as.character(sort(word.no))]
key.num <- as.list(key.num)
names(key.num) <- (1:word.num)*2
code.cut.eachnum <- c(word.pos,37)-c(0,word.pos)-1
code.cut.each <- split(code.cut,rep(((1:(word.num+1))*2-1),code.cut.eachnum))
code.cut.total <- c(code.cut.each ,key.num )
code.cut.total <- code.cut.total[sort(names(code.cut.total ))]
unsplitf <- sort(c(rep(((1:(word.num+1))*2-1),code.cut.eachnum),(1:word.num)*2))
code.trans <- unsplit(code.cut.total,unsplitf)
return(code.trans)
}
UnCode <- function(info){
code.info <- strsplit(info,"")[[1]]
a <- code.trans
names(a) <- code.ini
b <- a[code.info]
b <- paste(b,sep="",collapse="")
return(b)
}
code.ini <- c(0:9,LETTERS)
code.trans <- CodeTrans("JOBS")
info <- "8MLDQ6TUI6TFMLRHAANRA6Q8EFLDMQ86II2O32S5J13JXOJ"
UnCode(info)
"CONGRATULATIONSKEEPSEARCHINGORCALL6176390570X10" 凡事讲求创新,要比隔壁旁观者多走一小步,所以呢,克隆了一个一分相似的图片出来,题目为:跟Google联系完,请再跟我再联系。
CodeTrans <- function(key.word="JOBS"){
word.num <- nchar(key.word)
code.cut <- code.ini[-(1:word.num)]
word.pos <- grep(paste(strsplit(key.word,"")[[1]],sep="",collapse="|"),code.ini)
word.no <- match(strsplit(key.word,"")[[1]],code.ini)
key.num <- as.character(0:(word.num-1))
names(key.num) <- paste(word.no)
key.num <- key.num[as.character(sort(word.no))]
key.num <- as.list(key.num)
names(key.num) <- (1:word.num)*2
code.cut.eachnum <- c(word.pos,37)-c(0,word.pos)-1
code.cut.each <- split(code.cut,rep(((1:(word.num+1))*2-1),code.cut.eachnum))
code.cut.total <- c(code.cut.each ,key.num )
code.cut.total <- code.cut.total[sort(names(code.cut.total ))]
unsplitf <- sort(c(rep(((1:(word.num+1))*2-1),code.cut.eachnum),(1:word.num)*2))
code.trans <- unsplit(code.cut.total,unsplitf)
return(code.trans)
}
UnCode <- function(info){
code.info <- strsplit(info,"")[[1]]
a <- code.trans
names(a) <- code.ini
b <- a[code.info]
b <- paste(b,sep="",collapse="")
return(b)
}